Thursday, November 22, 2007

Oh boy oh boy oh boy (frantically)

.NET Framework 3.5 and Visual Studio 2008 are here! Can't wait to get my hands on this baby! I loved beta 2 and I found it to be very stable, compared to the beta versions of Visual Studio 2005 more than a year ago. I also love where C# is going, particularly the the automatic properties are excellent to reduce the amount of repetetive property access code that makes us more like monkeys typing stuff than programmers.

I also love the extension methods, lambda expressions, anonymous types and object initializers (examples below). But I'd really love to see optional parameters (like in VB.NET) someday. Oh well, the rest is cool enough for now. The only thing I haven't touched yet is Linq, which I'll be doing sometime soon I hope.

  • Extension methods:
    public static bool IsGuid(this string s)
    {
    // TODO: Add logic here, of course.
    return true;
    }

    From then on you can simply do:

    string test = "NotAGuid";
    if (test.IsGuid())
    {
    ....
    }

  • Anonymous types:
    var someObject = new { Name="Lobo", Profession="Sheriff", Salary=15500 },

  • Object initializers:
    Point point = new Point { X=15, Y=14 };

No comments: