Archives / 2007 / March
  • [Orcas] Extension Methods

    If you haven't already, head over to Scottgu's blog and read his excellent explanation of the Extension Methods feature, part of the "Orcas" release later this year. No need to show any example here, better to look at what Scott did, but with this feature you can add new methods to the public contract of ANY existing CLR type! Even Object itself. This feature is available in some dynamic languages already, and it's mighty cool. No need to subclass or anything. It will be available for both c# and VB.NET.

    Microsoft has really stepped into the dynamic languages arena with all these new features. It will be very interesting to see some of the productive stuff people will come up with soon where you combine these new features with LINQ. Ruby on Rails, watch up… I do hope the new stuff will also spice up the IronPython language.

    Scott ends his blog post with something important to keep in mind:

    Hopefully the above post gives you a basic understanding of how extension methods work, and some of the cool extensibility approaches you will be able to take with them.  As with any extensibility mechanism, I'd really caution about not going overboard creating new extension methods to begin with.  Just because you have a shiny new hammer doesn't mean that everything in the world has suddenly become a nail!