Check out this code:
static void Main(string[] args) { string test = null; Console.WriteLine("Is test null: " + test == null); Console.ReadLine(); }
And guess the output without running the code.
PingBack from http://foreachdev.net/blog/2007/06/28/testing-for-null/
Hi Josh,
Giuseppe is correct. The order of operators is misleading in this case. As a human you know what you want to achieve and it seems logical that it will work, but the operator precedence is not what you would think. :-) + has a precedence over ==.
One can find the operator precedence order here:
http://msdn2.microsoft.com/en-us/library/6a71f45d(VS.80).aspx
PingBack from http://foreachdev.net/blog/2007/06/28/implicit-casting-is-evil/