News for hackers. Stuff that matters.
Re:Stack Overflow open sources their ASP.net MVC mini profiler by bitdiffusion on Thursday June 09, 2011 @08:22AM (#2636844)
Extension methods can be invoked on null objects (the object gets passed to the static method and you can check for null in the extension itself).

Strange, but does enable some interesting syntactic sugar checking for empty values etc.

Re:Stack Overflow open sources their ASP.net MVC mini profiler by MatthewPhillips on Thursday June 09, 2011 @01:14PM (#2637858)
Nice. I've used extension methods from time to time but not in this way. Could prevent you from writing if foo != null a lot if you have an extension method by doing: public static bool Exists(this Foo foo) { return foo != null; }

So then you can say if(foo.Exists()) { foo.bar(); }

Or make Exists return an instance of Foo (foo if not null, a new Foo if not) and go with foo.Exists().bar();