The following shows MyEmpty, which is "" while I thought it would be null.
public class SomeClass
{
public static readonly String MyEmpty;
...
}
If MyEmpty is "" rather than null, does it have to be going like this below?
public class SomeClass
{
public static readonly String MyEmpty = "";
...
}
Somehow the 'readonly' makes that happen but why?
Thanks in advance.
[Edit]
I was testing these two using MessageBox.Show() assuming that the method would throw an exception when I give it a null value. But it didn't throw any exception at all, which is why I thought that in my first code MyEmpty was not null but "".
Thank you all for trying to explain the difference between null and "" and also my mistake.
String.Emptysomewhere? BecauseString.Emptyis an empty string (i.e."") and not anull. It isn't the same thing.""in the constructor of string