且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否有任何的优势编译用于.NET Framework 3.5,而不是2.0?

更新时间:2023-02-11 19:12:39

还有编译和目标之间的差异。

There's a difference between compiling and targeting.

编译code与(比如)C#3.0编译器可能会给你的性能提升(非常小家伙反正)一些优化生成的IL code migh已被列入。它也可以让你使用一些像自动属性或λEX pressions的新功能。

Compiling the code with the (for example) C# 3.0 compiler will probably give you a boost on performance (very little one anyway) as some optimization for the generated IL code migh have been included. It also allows you to use some of the new features like automatic properties or lambda expressions.

定位对于一个给定的框架,将确保您的装配工作在该框架(和后验),如果你的目标为2.0,并采用了一块3.5库将失败。没有性能的提升将直接关系到你的,除非从一个框架,另一个最快级替代的类。例如,针对.NET 1.1将不会允许您使用仿制药,因此,你将不得不使用比列表慢得多ArrayList中(由于装箱和拆箱)。

Targeting for a given framework will ensure your assembly works for that framework (and posteriors) and will fail if you target for 2.0 and are using a 3.5 library. No performance improvements will be directly related to that unless your substituting a class from one framework with another "fastest" class. For example, targeting .NET 1.1 won't allow you to use generics and therefore you'll have to use the ArrayList which is considerably slower than List (due to boxing and unboxing).