I was browsing the Hidden Features of C# question and thought I would try out one of the features I was unfamiliar with. Unfortunately I use Visual Studio 2005 and the feature in question was introduced later. Is there a good list for new features in C# 3.0 (Visual Studio 2008) vs. C# 2.0 (Visual Studio 2005)?
C# – new in Visual Studio 2008 vs 2005 or C# 3.0 vs C# 2.0
.net-2.0.net-3.0cvisual-studio-2005visual-studio-2008
Best Answer
This is not a comprehensive list but these are some of my favorite new features of C# 3.0:
New type initializers. Instead of saying this:
I can say this:
Similarly, instead of adding items individually, I can initialize types that implement IEnumerable like this:
The new syntax for lambda expressions is also nice. Instead of typing this:
I can type this:
You can also write extension methods to built in types:
Which allows something like this:
And finally. Anonymous types. So you can create anonymous classes on the fly, like this: