11
I just got this quiz from a colleague that is driving me crazy. For this snippet of code:
var x = new Int32?();
string text = x.ToString(); // No exception
Console.WriteLine(text);
Type type = x.GetType(); // Bang!
Why does the first part .ToString() works without throwing an exception and then the call to GetType() throws a NullReferenceException ?