C#.NET 3.0 / 3.5在2.0的功能使用Visual Studio 2008功能、NET、Studio、Visual

2023-09-02 21:33:05 作者:剑下孤魂

什么是一些可以在.NET 2.0中使用的新功能是专门针对C#3.0 / 3.5升级到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?

可用

lambda表达式 扩展方法(通过声明一个空System.Runtime.CompilerServices.ExtensionAttribute) 自动性能 对象初始化 集合初始化 LINQ到对象(通过实现IEnumerable的扩展方法,请参见 LinqBridge ) 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)

不可用

防爆pression树 在WPF / Silverlight库

推荐答案

您可以使用由编译器处理通过发射2.0兼容的IL,根本不涉及任何新的3.5组件的任何新的C#3.0的功能:

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:

在Lambda表达式(用作 Func键&LT; ..&GT; ,不是防爆pression&LT; Func键&LT; ..&GT;&GT; ) 扩展方法(通过声明一个空System.Runtime.CompilerServices.ExtensionAttribute) 自动性能 对象初始化 集合初始化 LINQ到对象(通过实现IEnumerable的&LT; T&GT;扩展方法,请参见 LinqBridge ) 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)