Keith Smith wrote:
Are these two statements identical?
public static string Var1 = "";
public static string Var1 = null;
I read somewhere that there was a difference, but I haven't found it.
Any ideas?
Why on earth should these be identical?
The first line assigns the empty string (a live object) to Var1. The
second line assigns, um, nothing (i.e. no live object) to Var1.
So
Console.WriteLine(Var1);
Console.WriteLine(Var1.Length);
Console.WriteLine(Var1.GetHashCode());
will work fine for "", but will crash on the second line for null.
Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de