CodeAttest
VSTS, Oslo, INETA, ASP.NET, Debugging .NET Applications, Tips and Tricks

September 17, 2005

C# 3.0 specification

The C# 3.0 specification is available here. The new features include (along with my comments):

1. Implicitly typed local variables

Basically this means that one can write

var p = 3;

Come on dudes, this one makes me sick. I see its benefits using LINQ syntax, but it should not be allowed to be used anywhere else. This language will soon mutate to a JavaScript like.

2. Extension methods

Sucks, mucks, pucks, *ucks, and sucks all at one.
Allows you to extend one class functionality through another. Thus the following:

public static class Extensions
{
    public static int ToInt32(this string s)
    {
        return Int32.Parse(s);
    }
}


can be invoked using the code below:

string s = "1234";
int i = s.ToInt32(); // Same as Extensions.ToInt32(s)


Instead of removing the sealed keyword (it is OO language after all), now we have extension methods that can come from all over the code and extending every single object. Debug this one now. Sucks big times. ARHRGHRR.

3. Lambda expressions

I am against anonymous methods so I will save my comments on this one.

4. Object and collection initializers

As Stoyan Damov says, we expected this feature in C#1.0. What this means is that you can now write the following to initialize objects and collections:

Point p = new Point { X = 0, Y = 1 };

instead of

Point p = new Point { X = 0, Y = 1 };
p.X = 0;
p.Y = 1;

and

List digits = new List { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

instead of - you guess what.

5. Anonymous types

One more feature to make C# behave like a type less javascript or VB language. Creates a new type without naming it, hence – anonymous. Works with var keyword (see 1.)

var p1 = new { Name = "Lawnmower", Price = 495.00 };

6. Implicitly typed arrays

One more feature that should be available in C# 1.0. Allows you to create array without defining explicitly its size and type. The drawback is that the var keyword has took over this feature also. Thumbs down.

var[] a = new[] { 1, 10, 100, 1000 };

7. Query expressions

I wrote about query expressions in my previous post. Pretty big one. Still not sure if C# is the right language for this feature. Good idea, but I would prefer to be separated from the language.

8. Expression trees

This is too much for my brain capacity. I leave it for you :)


Eric Gunnerson has some comments about C# 3.0 specification also.

For now I am seriously considering to jump over C++/CLI implementation. Like the good old days :)

# posted by Martin Kulov @ 5:51 PM




This page is powered by Blogger. Isn't yours?

 




Calendar Martin Kulov's Calendar   RSS Aggregate this blog

DevReach - The Premier Conference for Microsoft Technologies for SEE

Mobility Day 2008 Conference

DevReach - The Premier Conference for Microsoft Technologies in Bulgaria

International Association of Software Architects

SofiaDev .NET User Group

Microsoft Most Valuable Professional

View Martin Kulov's profile on LinkedIn

MSDN Event Bloggers




Recent posts




History




 
Copyright © 2004-2008 CodeAttest Ltd. All Rights Reserved.