When discussing the new features in Visual Studio 2008, LINQ gets most of the press. However, LINQ only works if you are targeting the .NET 3.5 Framework. Another new feature of Visual Studio 2008 is the ability to choose which Framework version to target, and sometimes you just don’t have the luxury of upgrading all your users to the latest Framework. Fortunately several of the new language features in C# 3.0 don’t require library support, so here are some useful enhancements that work just fine when targeting the .NET 2.0 Framework.
- Lambda Expressions (more via Eric White and Scott Guthrie)
- Auto-Implemented Properties (more via Scott Guthrie and Dan Wahlin)
- Object and Collection Initializers (more via Dan Wahlin and developer.com)
- Implicitly Typed Local Variables (more via Scott Guthrie)
Extension Methods (more via developer.com and Scott Guthrie)
Update: It turns out that the compiler attaches an attribute to extension methods that is not defined in the .NET 2.0 library, so extension methods can only be used with .NET 3.5 after all.