When having a function Foo(object) and an overload Foo(Exception), calls to Foo(null) are evaluated by Foo(Exception). Why is this?
UPDATE: (so basically most but not all nulls gets resolved to Foo(Exception))
Exception e = new Exception();
e = null;
Foo bar = new Foo(e); //Evaulated by Foo(Exception)
Foo bar = new Foo((object)e); //Evaluated by Foo(object)
object o = null;
Foo bar = new Foo(o); //Evaluated by Foo(object)
Foo bar = new Foo(null); //Evaulated by Foo(Exception)
Foo bar = new Foo((object)null); //Evaulated by Foo(object)
Thanks everyone.
The compiler resolves it at compile time by the type of reference of the parameter. For example:
will be resolved to Foo(Exception e), in contrasts:
will be resolved to Foo(object o). Note that the type of the instance is not taken into account.