Lately, I've been playing with extension methods. Extension methods are a way to add custom functionality to data types that are already defined without creating a new derived type. On the surface extension methods appear to be adding methods to existing classes, but under the hood the compiler is abstracted what developer's have been doing or years, that is, write static helper methods. Creating extension methods in VB.NET or C# is simple and there are great posts that detail how it's done; Scott Hanselman, Visual Basic Developer Center and ScottGu, too name a few.
What about extension method libraries? It has been well over 5 months since the official release of VS 2008, are there many libraries out there that make use of extension methods. The answer is yes and here is a list that I have come up with. As I find more I will update this list.
- Dynamic LINQ: A set of extension methods that allow you to construct dynamic LINQ queries.
- XML Serialization: A few extension methods to serialize/de-serialize objects using XML.
- Lucas Extensions: Contains 40+ extension methods extending Bitmap, ByteArray, Enumerable, File, Math, Object, String classes, etc.
- Extension Toolkit: Extends a variety of classes, such as, String, DateTime, Cache, etc.
- DateTime Extensions: A set of fluent extension methods for System.DateTime.
- Extension Method: A web site devoted to extension methods. As of April 15, 2008 they were 68 methods.
Guess the movie (From a movie I didn't particularly like, but westerns apparently do. Come on you know whom I am referring to.)
I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking. And I plan on finding out what that is.