C#4、5和6编译器的特定版本号是什么,以及如何知道使用哪个Visual Studio编译我的项目? [英] What are the specific version numbers of the C# 4, 5 and 6 compilers and how to know which one Visual Studio is using to compile my project?

查看:809
本文介绍了C#4、5和6编译器的特定版本号是什么,以及如何知道使用哪个Visual Studio编译我的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我拥有C#6编译器,并且经常使用C#6功能,并且在编写应用程序进行练习时,通常会以.NET v4.6为目标.

I know that I've got the C# 6 compiler and I use C# 6 features often and when I write applications to practice, I usually target .NET v4.6.

在这台计算机上,我安装了Visual Studio 2010、2013、2015和2017.

On this machine, I have Visual Studio 2010, 2013, 2015 and 2017 installed.

当我从.NET Framework v4目录键入csc.exe时,它向我显示了C#5的编译器版本为 4.6.1098.0 ,这非常令人困惑.

When I type csc.exe from the .NET Framework v4 directory, it shows me the compiler version as 4.6.1098.0 for C# 5, which is very confusing.

C:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319> csc Microsoft(R) 适用于C#5的Visual C#编译器版本4.6.1098.0(C)Microsoft 公司.保留所有权利.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>csc Microsoft (R) Visual C# Compiler version 4.6.1098.0 for C# 5 Copyright (C) Microsoft Corporation. All rights reserved.

此编译器是Microsoft(R).NET Framework的一部分, 但仅支持不超过C#5的语言版本, 最新版本.对于支持较新版本的C#的编译器 编程语言,请参见 http://go.microsoft.com/fwlink/?LinkID=533240

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

当我在我只安装了Visual Studio 2013的另一台笔记本电脑上键入相同的命令时,我从csc.exe命令获得以下输出.

And when I type the same command on another laptop of mine where I have only Visual Studio 2013 installed, I get the following output from the csc.exe command.

C:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319> csc Microsoft(R) 适用于C#5的Visual C#编译器版本4.6.1055.0(C)Microsoft 公司.保留所有权利.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>csc Microsoft (R) Visual C# Compiler version 4.6.1055.0 for C# 5 Copyright (C) Microsoft Corporation. All rights reserved.

此编译器是Microsoft(R).NET Framework的一部分, 但仅支持不超过C#5的语言版本, 最新版本.对于支持较新版本的C#的编译器 编程语言,请参见 http://go.microsoft.com/fwlink/?LinkID=533240

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

观察到对于C#5读为 4.6.1055.0 .

Observe that it reads 4.6.1055.0 for C# 5.

  1. 所以,我的第一个问题是:C#4、5和6的C#编译器的不同版本号是什么?

  1. So, my first question is: what are the different version numbers of the C# compilers for C# 4, 5 and 6?

第二,如何知道我的Visual Studio安装正在使用哪个版本的csc.exe文件以及哪个版本的C#编译器来编译我的文件?为了自己尝试,我在两台计算机上都创建了一个控制台应用程序,并跟踪了项目文件.它们都具有MS Build bin文件夹中Microsoft.Csharp.targets文件的MS Build Import指令.但是我放弃了从该文件内部进行读取的操作,因为我仍然不完全了解所有的MS Build标签.

Second, how do I know which version of the csc.exe file, and thus which version of the C# compiler, my Visual Studio installation is using to compile my files? To try this on my own, I created a console application on each of my two machines and chased down the project files. They both had an MS Build Import directive for the Microsoft.Csharp.targets file from the MS Build bin folder. But I gave up reading from inside that file because I still don't fully understand all of the MS Build tags.

推荐答案

用于C#4、5和6的C#编译器的版本号是什么?

what are the different version numbers of the C# compilers for C# 4, 5 and 6?

作为最新的C#版本此处,Visual Studio 2010和Visual Studio 2013年使用C#4& 5编译器,正如Cody Gray所说,编译器是向后兼容的,这意味着C#5编译器可以针对较旧版本的C#.因此它们都是C#5.此外,从Visual Studio 2013开始,MSBuild和C#编译器现在作为独立软件包Microsoft®Build Tools提供.该软件包与Visual Studio 2013一起安装.然后您可以从以下路径获取C#6的版本号:C:\ Program Files(x86)\ Microsoft Visual Studio 14.0

As the latest C# versions here, Visual Studio 2010 and Visual Studio 2013 are use the C# 4 & 5 compiler, and just as Cody Gray said, the compilers are backwards-compatible, meaning that the C# 5 compiler can target an older version of C#. So they are both C# 5. Besides, starting with Visual Studio 2013, MSBuild and the C# compilers are now available as a standalone package,Microsoft® Build Tools. This package is installed with Visual Studio 2013. Then you can get the version number of the C# 6 from the path: C:\Program Files (x86)\Microsoft Visual Studio 14.0

我怎么知道我的Visual Studio安装正在使用哪个版本的csc.exe文件,以及哪个版本的C#编译器来编译我的文件?

how do I know which version of the csc.exe file, and thus which version of the C# compiler, my Visual Studio installation is using to compile my files?

MSBuild文件夹中的csc.exe文件是MSBuild内部使用的.您可以从以下路径获取C#编译器版本:C:\Program Files (x86)\Microsoft Visual Studio 14.0\csc.exe

The csc.exe file in MSBuild folder is internal used by MSBuild. You can get the C# compiler version from the path: C:\Program Files (x86)\Microsoft Visual Studio 14.0\csc.exe

这篇关于C#4、5和6编译器的特定版本号是什么,以及如何知道使用哪个Visual Studio编译我的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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