简体   繁体   English

.NET Framework版本与C#语言版本的关系

[英].NET Framework Version relationship with C# language version

I've inherited an app. 我继承了一个应用程序。 The app has to use .NET 2.0. 该应用程序必须使用.NET 2.0。 However, I would like to make use of a feature introduce in C# 4.0 (optional arguments). 但是,我想利用C#4.0中的功能介绍(可选参数)。 I understand that a framework is separate from a language. 我了解框架与语言是分开的。 However, what I'm not sure of is, can I use this C# feature in the context of .NET 2.0? 但是,我不确定的是,是否可以在.NET 2.0的上下文中使用此C#功能?

The code compiles. 代码会编译。 I wasn't sure if this was legitimate, or if I just got lucky :). 我不确定这是否合法,或者我是否很幸运:)。

Thank you for your insights. 感谢您的见解。

Optional arguments/parameters have been supported in CLR since CLR 1.0. 从CLR 1.0开始,CLR支持可选参数/参数。 This is due to CLR support for VB.net. 这是由于对VB.net的CLR支持。

This is why your code compiles. 这就是您的代码编译的原因。 Other new 4.0 features may not work the same. 其他新的4.0功能可能无法正常工作。

Other post-C# 2.0 features that will compile into a .NET 2.0 application include named arguments, lambda expressions, auto properties, & extension methods. 将编译到.NET 2.0应用程序中的其他C#2.0后功能包括命名参数,lambda表达式,自动属性和扩展方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM