是否有C#4.0的工作,在.NET 3.5中的更改列表? [英] Is there a list of changes for C#4.0 that work in .Net 3.5?

查看:206
本文介绍了是否有C#4.0的工作,在.NET 3.5中的更改列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了很多C#4.0变化为晚。我真的很喜欢其中的一些。此外,虽然,我不希望在移动到.NET 4.0的兼容性的原因,只是还没有。

I've been seeing a lot of C# 4.0 changes as of late. I really like some of them. Also though, I do not want to move on to .Net 4.0 for compatibility reasons just yet.

那么,有没有新的C#4.0的语言特性,将工作的.Net 3.5或更低的COM prehensive名单?

So, is there a comprehensive list of new C# 4.0 language features that will work on .Net 3.5 or lower?

作为一个例子,就默认参数需要.NET 4.0 CLR,或者是他们一个编译器功能?它可以使用自动属性(一个C#3.0的功能),仍然面向.NET 2.0,因为这不需要Framework的支持,而不是使用LINQ EX pressions,因为这确实需要框架3.5。

As an example, do default parameters require the .NET 4.0 CLR, or are they a compiler feature? It's possible to use automatic properties (a C# 3.0 feature) and still target .NET 2.0, since that doesn't require Framework support, but not to use LINQ expressions, since that does require Framework 3.5.

请不要说当然C#4.0中的.Net 3.5将无法正常工作的原因,而是旧的

Please don't say "of course C#4.0 won't work in .Net 3.5 cause it's older"

推荐答案

C#编译器4.0附带了一个新的multitargeting功能。短版本是,它会产生与任何元数据版本为present在定义System.Object的(通常mscorlib.dll中)的参考的组件。这使您可以使用它来编译为2.0和3.5组件,以及各种版本的Silverlight。该功能在支持Visual Studio 2010中的multitargeting的。

The C# compiler in 4.0 ships with a new multitargeting feature. The short version is that it will produce an assembly with whatever metadata version is present in the reference that defines System.Object (usually mscorlib.dll). This allows you to use it to compile assemblies for 2.0 and 3.5, as well as various versions of Silverlight. This feature was introduced in support of the multitargeting in Visual Studio 2010.

因此​​,您可以使用C#4.0编译器来编译3.5组件,并利用任何你想要的C#4的功能,所以只要有4.0的库没有特别的依赖。例如,命名参数和可选参数将正常工作,因为他们不使用任何4.0框架功能。动力,然而,这等开箱它不会在3.5工作。

Therefore, you can use the C# 4.0 compiler to compile 3.5 assemblies, and make use of whatever C# 4 features you want, so long as there is no particular dependency on 4.0 libraries. For example, named arguments and optional parameters will work fine, because they don't use any 4.0 framework features. Dynamic, however, does, and so out of the box it won't work on 3.5.

有一个关于这张贴在这里,涵盖了基础知识。

There is a post about this here, that covers the basics.

<一个href="http://blogs.msdn.com/ed_maurer/archive/2010/03/31/multi-targeting-and-the-c-and-vb-compilers.aspx">http://blogs.msdn.com/ed_maurer/archive/2010/03/31/multi-targeting-and-the-c-and-vb-compilers.aspx

短名单(埃德的职位)是:

The short list (from Ed's post) is:

  • 命名参数和可选参数
  • 在某些COM语法改进(例如,省略参考)
  • 通用​​方差

东西,将无法正常工作包括动态和无PIA(我们两个最大的支出在时间上花了实现它们)。前者要求框架的支持,而后者需要运行时支持。

Things that won't work include dynamic and no-pia (our two biggest outlays in terms of time spent implementing them). The former requires framework support and the latter requires runtime support.

这篇关于是否有C#4.0的工作,在.NET 3.5中的更改列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆