C# – What features of .NET 3.5 can be used in a .NET 2.0 application

.net-2.0.net-3.5ccompiler-construction

I have an app that I am developing in Visual Studio 2008, but the projects are set to .NET 2.0. The application will run on a box that only has .NET 2.0 installed.

I understand that I can use some of the features of the .NET 3.5 c# compiler and that it compiles my code to MSIL that .NET 2.0 runtime understands.

What are the features of .NET 3.5 that I can use in my .NET 2.0 app?

Edit: what I have in mind is Extension Methods, Linq, lambdas, object initializers, collection initializers and other compiler candy.

Best Answer

With no external libraries you can use

  • Lambda expressions
  • Object Initializers
  • Collection Initializers
  • Extension Methods
  • Autoproperties

With the help of an external library like LINQBridge you can also use in memory LINQ queries.

The main feature you cannot use are expression trees because they rely on fixes in the CLR which are not present in a vanilla 2.0 install