What are some of the new features that can be used in .NET 2.0 that are specific to C# 3.0/3.5 after upgrading to Visual Studio 2008? Also, what are some of the features that aren't available?
Available
- Lambdas
- Extension methods (by declaring an empty System.Runtime.CompilerServices.ExtensionAttribute)
- Automatic properties
- Object initializers
- Collection Initializers
- LINQ to Objects (by implementing IEnumerable extension methods, see LinqBridge)
Not Available
- Expression trees
- WPF/Silverlight Libraries
Best Answer
You can use any new C# 3.0 feature that is handled by the compiler by emitting 2.0-compatible IL and doesn't reference any of the new 3.5 assemblies:
Func<..>
, notExpression<Func<..>>
)System.Runtime.CompilerServices.ExtensionAttribute
)IEnumerable<T>
extension methods, see LinqBridge)