C# 3.0

By Deane Barker on January 31, 2007

C# 3.0 new language features; Maybe I’m just sheltered, but some of the new features of C# 3.0 look insanely cool. Especially this one:

Extension methods (adding methods to classes by including the this keyword in the first parameter of a method on another static class).

Here’s the example;

public static class IntExtensions 
{
    public static void PrintPlusOne(this int x) { Console.WriteLine(x + 1); }
}
int foo = 0;
foo.PrintPlusOne();

I can’t quite figure out how this is any better than extending some object, but it will still go a long way when it comes time to fix someone’s crappy object model that you have to work with.

The LINQ stuff looks snazzy too. It’s like SQL for anything.

I really do enjoy writing C#. In the end, it’s the ASP.Net framework that drives me up the wall. C# by itself is a really, really well-done language. I say give me a .Net Smarty implementation, and I’ll be good to go.

Gadgetopia