nvm, the following code prints true for s1 = "test" and false for "test "
string s1 = "test";
string s2 = s1.Trim();
Console.WriteLine(object.ReferenceEquals(s1, s2));
Type: Posts; User: KIBO
nvm, the following code prints true for s1 = "test" and false for "test "
string s1 = "test";
string s2 = s1.Trim();
Console.WriteLine(object.ReferenceEquals(s1, s2));
strings are immutable classes, fine
but consider the Trim function. What happens when Trim finds out theres nothing to trim. Will it do just "return this" or "return new string(this)"
??
Got working with AppDomain.DoCallback which executes the code in the new AppDomain and doesnt load the assembly in the main AppDomain
AppDomainSetup setup = new AppDomainSetup();...
I used to have this code which loads an assembly:
Assembly assembly = Assembly.LoadFrom(assemblyName);
It works fine but now I need to load it into a separate AppDomain.
consider this code:
private void DoIf(bool b, Action f)
{
if (b)
f();
}
int x = 0;
Or check what Environment.CurrentDirectory returns and use a relative path to your dll. Thats a bit safer and a little more freedom to move your app around
agree on the naming part (except that default cant be used, its a keyword)
disagree on the not catching exceptions part. Convert.ToBoolean throws an exception too if it cant be formatted so...
No question in this post, just something you might put to good use too:
I got sick of this code that uses Configurationmanager all over the place
bool b;
string s =...
GetOverlappedResult helped indeed, there were still bytes pending to be written. Thanks!
So the correct order of closing a serial port would be:
GetOverlappedResult(hPort, ptrUWO, out sent,...
It's an access violation, not a .NET exception
Consider the following code which closes an overlapped I/O serial handle during application shutdown.
Win32Com.CancelIo(hPort);
Win32Com.CloseHandle(hPort);
It works fine...
thanks people, I found out that ildasm is still in the SDK that was good enough. I needed to see if a certain function was in a deployed assembly to rule out if that was why my code was crashing....
is there a tool to find all functions and classes in an assembly?
Whats the advantage of using AsParallel on an array opposed to just using the array directly?
al.ToArray().AsParallel().ForAll(po => CacheToAppFabric((MyObject)po));
the following code prevents windows from letting the monitor go into sleep mode when the program is active and wakes the monitor up after a scanner scans something.
protected override...
I see, thanks
Consider this code:
class Test : IDisposable
{
public void Dispose()
{
Console.WriteLine("dispose");
}
Is it useful to use SqlTransaction and transaction.commit() or rollback when only reading from a database? Have some code here that does that
How can you get a monitor out of sleep mode in c#?
I tried the following, but then the monitor wakes up and falls back to sleep mode immediately.
uint SC_MONITORPOWER = 0xF170;
uint...
I want to sort a list of price object by year but it just doesn't sort
var query = from p in prices orderby p.StartDate descending select p;
Is it possible to sort with LINQ on a certain...
No, like a tool that shows relations between objects. When one object uses 10 times another object it would show 10 lines between the objects. I want to get the amount of coupling exposed
Is there a tool for C# that exposes coupling between objects by makeing a visual representation of the software?
Im learning c# and making software at the same time. So ye Im guessing a lot on how to optimize things but this part needs optimization. Its a database which takes half an hour to retrieve which uses...
I have a dictionary which maps a Guid to Orders, it contains like 350000 orders
Dictionary<Guid, Order> htPreOrders = new Dictionary<Guid, PreOrder>(350000);
Im trying to optimize it by...
Why doesnt the following compile? the c in prices.Where() is not a declared variable in this scope right? Sounds like a compiler bug to me or am I missing something?
int c = 0;
List<Price>...