Problem solve Get help with specific problems with your technologies, process and projects.

On Extension Methods in C# and .NET Framework 3.5

Blogger Alex Hoffman's "Adventures in .NET 3.5" offers quite a bit of advice for the C# architect on working with Extensions Methods.

As Visual Studio 2008 and the .NET Framework 3.5 spend more time in the wild, developers and architects are increasingly turning to the blogosphere both to see what the new IDE has to offer and to share lessons learned from the trenches.

One software architect in the latter category is Alex Hoffman, who recently wrote five blog posts under the heading "Adventures in .NET 3.5." In each post Hoffman shares a thing or two he has learned along the way.

Adventures in the .NET Framework 3.5, Part 1 takes a look at Extension Methods, which make it easy for an object to, as it were, print itself to the console. There's also a C# code snippet to implement concatenation once the aforementioned print method has done its thing.

More on Extension Methods in Visual Studio 2008
Visual Basic team offering Extension Methods tutorials 

Adventures in the .NET Framework 3.5, Part 2 expands on the Extension Method, demonstrating how it can be used to implement an Each method. Doing so gives C# code some of the same power as Ruby Blocks.

Adventures in the .NET Framework 3.5, Part 3 shows how the new compiler can infer a collection's type. Hoffman then provides some C# code for creating a public delegate, creating an Extension Method, and applying the Concatenate and Print methods to a collection.

Adventures in the .NET Framework 3.5, Part 4 builds on the Transform method form the previous post to do even more with the resulting collection.

Adventures in the .NET Framework 3.5, Part 5 (published with the headline "CodeDomProvider -- Targeting .NET 3.5" but tagged as a continuation of the adventure) offers the C# code needed to target the .NET Framework 3.5 if one is using a CodeDomProvider for code compilation. This is necessary because, by default, the CodeDomProvider targets the .NET Framework 2.0, Hoffman points out.

Dig Deeper on C# programming language

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.