面向.NET 2.0的VS2008不会阻止我使用C#3功能 [英] VS2008 targeting .NET 2.0 doesn't stop me from using C# 3 features

查看:71
本文介绍了面向.NET 2.0的VS2008不会阻止我使用C#3功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VS2005解决方案,并希望在新的一年开始使用VS2005.我对升级过程非常满意,并高兴地看到我的构建脚本仍然可以正常工作.

I had a VS2005 solution and wanted to get off VS2005 for the new year. I was mostly happy with the upgrade process and pleasantly surprised to see that my build scripts mostly still worked.

我的问题是关于多目标功能的问题-我的服务器上没有安装.NET 3.5,因此我必须继续以.NET 2.0为目标.大多数情况下都可以,但是我发现我可以做

My question is around the multi-targeting feature - I don't have .NET 3.5 installed on my servers, so I have to continue to target .NET 2.0. That worked, mostly, but I found that I could do things like

var returnMe = "result: " + result.ToString();

...并且仍然成功调试项目.

...and still debug the project successfully.

当我将该代码提交到构建服务器时,构建失败,并说未定义"var".

When I got that code up to the build server, the build failed, saying that "var" wasn't defined.

那么,我应该期待什么?

So, which should I be expecting?

  1. 针对.NET 2.0的VS2008,当我尝试执行C#3事情时应该抛出错误
  2. 构建服务器意识到我的目标是.NET 2.0,因此应该了解我在做什么,并将其编译为与2.0兼容的二进制文件

有什么想法吗?

推荐答案

问题似乎是构建服务器没有正确的编译器.您可以在工作站上构建它,对吗?

The problem appears to be that the build server does not have the right compiler. You can build it on your workstation, right?

.NET 3.0的许多功能"只是语法位,在编译时会还原为CLR 2代码. var 是其中之一-编译时,编译器会将var转换为适当的类型.

Many of the .NET 3.0 "features" are just syntax bits that revert to CLR 2 code at compile time. var is one of them -- when it compiles, the compiler converts var to the appropriate type.

查看全文

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