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
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 π