可Visual Studio的目标除了早期.NET framework版本较早的C#语法?
容易的部分:
面向.NET 2.0框架在使用Visual Studio中的下拉2010项目
Targeting the .NET 2.0 framework in a Visual Studio 2010 project using the dropdown.
困难的部分:
是否有可能针对特定语法的版本 - 例如变种s =Hello World的
在VS2008及以上的有效语法糖,但在VS2005不会编译。可以VS2010配置为标志,这在编译时?
Is it possible to target a specific syntax version - for example var s = "hello world"
is valid syntactic sugar in VS2008 and above, but would not compile in VS2005. Can VS2010 be configured to flag this at compile time?
这可以通过在项目设置中指定的语言版本来完成。要设置语言版本的C#2.0做以下
This can be done by specifying the language version in the project settings. To set the language version to C# 2.0 do the following
- 右键单击该项目,并选择属性
- 转至构建标签
- 单击高级按钮
- 更改语言版本下拉菜单ISO -2
- Right Click on the project and select "Properties"
- Go to the "Build" Tab
- Click the "Advanced" Button
- Change the "Language Version" drop down to "ISO-2"
下面是Visual Studio中的其它选择及其含义2010年
Here are the other selections and their meanings in Visual Studio 2010.
- ISO-1:C#1.0 / Visual Studio的RTM和2003
- ISO-2:C#2.0 / Visual Studio 2005中
- C#3.0:C#3.0 / Visual Studio 2008中
- 默认:C#4.0 / Visual Studio 2010中
- ISO-1: C# 1.0 / Visual Studio RTM and 2003
- ISO-2: C# 2.0 / Visual Studio 2005
- C# 3.0: C# 3.0 / Visual Studio 2008
- default: C# 4.0 / Visual Studio 2010