The C# 3.0 specification is available
here. The new features include (along with my comments):
1. Implicitly typed local variablesBasically 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 methodsSucks, 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 expressionsI am against anonymous methods so I will save my comments on this one.
4. Object and collection initializersAs
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 typesOne 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 arraysOne 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 expressionsI 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 treesThis 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
