About 6 months ago I left a comment here, and I returned now to check it, and found a real gem. Check this out, it is about invoking methods on null, like this:
Foo foo = null;
Wesner Moise explains what the possibilities are:
... An instance method can treat an null in special, default way to maintain continuity with nonnull objects and eliminate the need for callers to perform null checks. One example of this is how it simplifies the manipulation of binary trees. It's similar to the null object pattern, with the null object being null.
I can certainly think of several ways that this would be nice to use. It was removed from C# by the ECMA during the standardization process. It may be a good thing, I don't know if stuff like this are good (because they open up possibilities) or bad, because they mean more stuff to care about. Anyway, I'm not sure that I would ever want to see something like "if (this == null)" in my code any time soon.
One thing to note, this is supported by the CLR. C# will emit a callvirt IL call, which will cause a null reference exception, but this IL works just fine with no exceptions ( showing just the call, see the C# source below):
This translate to this C# call (except for the call vs. callvirt, of cours):
public class TestNullMethodInvocation
public static void Main(string args)
Inner inner = null;
bool result = inner.InstanceMethod();
public class Inner
public bool InstanceMethod()