Monday, November 5, 2007

Babies, Butterflies, Quotes

language features C # 3.0 and how to change the world

The. NET Framework 3.5 are again several features to the language C # 3.0 added to ease the developer's life much (unless you are on the maintenance page ).
Automatic Properties, offering Extension Methods, Lambda Expressions, Anonymous Types, etc., the developer of new ways, which can lead to very stylish code. With excessive Apply only the features or the elegance for which can lead to difficult and complex code visible presence and voice excesses.

Nevertheless, very nice is this (even if not very useful ;-):
7.TimesPrint ("my text");

elegant as essential: int
for (i = 0; < 7; i++)

{Console.WriteLine ( "my text");
}

But to make it work's needs another extension method:
public static void Times print (this int no, string s int)
{
for (i = 0; < no; i++)
{
Console.WriteLine ( s);}

}

Somewhat more generally could the call look like this and so does really make sense (the extension method must of course be adjusted accordingly):
7.Times (i => Console.WriteLine ("my text"));


Whether the maintainability of the major visible functionality is complex or the elegant syntax makes it more likely will show the latest practice.

Either way, the new features a lot of fun!

PS: A good overview of the new features here's .