Overload resolution and null
My colleague Soundar discovered this rather interesting behavior. 1: class Test 2: { 3: public static void Main() 4: { 5: Test test = null; 6: 7: Console.WriteLine("{0}", test); 8: Console.WriteLine("{0}", null); 9: } 10: } If you run this code, you’ll find that while line 7 prints an empty line, line 8 causes an ArgumentNullException. Note that the test reference is also null, so it should certainly surprise you that the two lines result in different behavior at runtime. It certainly surprised me enough to make me dig deeper into the reason for the difference. I reasoned that given … Continue reading Overload resolution and null