Thursday, November 26, 2009

I started to use features from C# .NET 3.5

I started to use 3 new features i c#.NET 3.5


1) extension method,

I call this  "static  noon-static" :)

such extension method help get user names in one string for the collection

public static string Namen(this List<Benutzer> instance)
{

var namen = new StringBuilder();
foreach (var benutzer in instance)
{

if (namen.Length > 0)
{

namen.Append(", ");

}
namen.Append(benutzer.Vorname);

}
return namen.ToString();

}


2) Auto-Implemented Properties, code snippet in VisualStudio 2008  "prop"

[DataMember]
public stirng Wert { get; set; }

[DataMember]
public string WertTyp { get; set; }


3) implicit type declaration

var masse = new Masse();



No comments:

Post a Comment