Since the called overloaded function is determined at compile time, it is determined by the static type of the parameter:
String.Format(null, "foo")
calls String.Format(IFormatProvider, string, params Object[]) with an empty IFormatProvider and the format string "foo", which is great.
On the other hand,
String.Format((string)null, "foo")
calls String.Format(string, object) with a null value as the format string that throws an exception.
source share