Possible Duplicate:
C#: Passing null to overloaded method – which method is called?
Consider these 2 methods:
void Method(object obj) { Console.WriteLine("object"); }
void Method(int[] array) { Console.WriteLine("int[]"); }
When I try calling:
Method(null);
in Visual Studio 2008 SP1 I get int[].
Why is this?
It is a product of overload resolution. Your argument,
null, is convertible to bothobjectandint[]. The compiler therefore picks the most specific version, becauseint[]is more specific thanobject.