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

前端 未结 7 1958
醉话见心
醉话见心 2020-12-09 05:27

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 tha

7条回答
  •  温柔的废话
    2020-12-09 05:49

    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> )
    • 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)

提交回复
热议问题