Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# .NET 3.0/3.5 features in 2.0 using Visual Studio 2008

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
like image 347
Russell Myers Avatar asked Oct 06 '08 02:10

Russell Myers


1 Answers

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:

  • Lambdas (used as Func<..>, not Expression<Func<..>> )
  • Extension methods (by declaring an empty System.Runtime.CompilerServices.ExtensionAttribute)
  • Automatic properties
  • Object Initializers
  • Collection Initializers
  • LINQ to Objects (by implementing IEnumerable<T> extension methods, see LinqBridge)
like image 124
Lucas Avatar answered Oct 12 '22 00:10

Lucas