我想知道我使用的是哪个版本的c#。 如果我要使用python,我会从命令行执行类似python -V的操作,或者键入:
import sys
print sys.version
在PHP中,我会这样做:phpinfo();java中:java -version
但是我不知道如何在c#中实现这一点。
这个问题并没有回答这个问题,尽管它的名字表明它应该回答这个问题。
我知道这取决于。net框架,但是否有一种编程方式来确定我的框架?我的意思是不需要进入目录并检查。net文件夹的名称。
我想知道我使用的是哪个版本的c#。 如果我要使用python,我会从命令行执行类似python -V的操作,或者键入:
import sys
print sys.version
在PHP中,我会这样做:phpinfo();java中:java -version
但是我不知道如何在c#中实现这一点。
这个问题并没有回答这个问题,尽管它的名字表明它应该回答这个问题。
我知道这取决于。net框架,但是否有一种编程方式来确定我的框架?我的意思是不需要进入目录并检查。net文件夹的名称。
当前回答
对于Windows,您在命令/搜索程序行中运行dev,并为vs选择开发人员命令提示符,然后您将运行
csc
现在你得到了类似于
Microsoft (R) Visual C# Compiler version 2.6.0.62329 (5429b35d)
Copyright (C) Microsoft Corporation. All rights reserved.
对于Windows,如果以cmd终端启动
cd C:\Windows\Microsoft.NET\Framework\
dir
现在你看到所有的目录和文件在。net \Framework\ Please,选择v…比如,最近去那里,
cd v4.0.30319
Run
csc
你会看到关于c#编译器版本的信息,这可以是类似的
Microsoft (R) Visual C# Compiler version 4.7.2556.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.
其他回答
要获得框架的版本-查看一个主要程序集的版本。
Console.Write(typeof(string).Assembly.ImageRuntimeVersion);
获取c#编译器的版本有点困难,但你应该能够通过检查使用的框架版本来猜测版本。
如果你正在使用命令行编译器(csc.exe),你可以检查帮助查看版本(同时你也需要知道框架版本:
C:\Windows\Microsoft.NET\Framework\v4.0.30319>csc /?
Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
你所使用的c#版本完全取决于你所使用的。net版本。
如果你使用visual studio进行开发,你可以选择。net框架版本 与之相关的c#版本也随之而来
以下是已知的c#版本:
C# 1.0 released with .NET 1.0 and VS2002 (January 2002) C# 1.2 (bizarrely enough); released with .NET 1.1 and VS2003 (April 2003). First version to call Dispose on IEnumerators which implemented IDisposable. A few other small features. C# 2.0 released with .NET 2.0 and VS2005 (November 2005). Major new features: generics, anonymous methods, nullable types, iterator blocks C# 3.0 released with .NET 3.5 and VS2008 (November 2007). Major new features: lambda expressions, extension methods, expression trees, anonymous types, implicit typing (var), query expressions C# 4.0 released with .NET 4 and VS2010 (April 2010). Major new features: late binding (dynamic), delegate and interface generic variance, more COM support, named arguments and optional parameters C# 5.0 released with .NET 4.5 in August 2012.
参考Jon Skeet的c#版本回答
.NET版本通过注册表
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\探索子程序并查看每个版本。键为'Full'的是系统上的版本。
https://support.microsoft.com/en-us/kb/318785 https://msdn.microsoft.com/en-us/library/hh925568 (v = vs.110) . aspx
.NET版本通过Visual Studio
Help ->关于Microsoft Visual Studio -> . net版本在右上角指定。
据我所知,Visual studio在操作系统中使用。net框架。
Visual Studio中项目的目标.NET框架版本可以通过项目属性->应用程序->目标框架来修改
通过dll
如果你知道。net Framework目录 例如C:\Windows\ Microsoft.NET \ Framework64 \ v4.0.30319
打开System.dll,右键单击->属性->详细信息选项卡
c#版本
帮助->关于Microsoft Visual Studio
在已安装的产品列表中有Visual c#。在我的案例中是Visual c# 2015
Visual Studio(微软)将c#命名为Visual c#。
https://msdn.microsoft.com/en-us/library/hh156499.aspx
c# 6, Visual Studio .NET 2015 当前版本,见下文
如果你正在使用VS2015,那么按照下面的步骤来找到相同的:
右键单击项目。 单击Properties选项卡。 从属性窗口选择“构建”选项。 然后点击Advance按钮。 在那里你会找到语言版本。
下面的图片显示了相同的步骤:
步骤1:
步骤2:
对于Windows,您在命令/搜索程序行中运行dev,并为vs选择开发人员命令提示符,然后您将运行
csc
现在你得到了类似于
Microsoft (R) Visual C# Compiler version 2.6.0.62329 (5429b35d)
Copyright (C) Microsoft Corporation. All rights reserved.
对于Windows,如果以cmd终端启动
cd C:\Windows\Microsoft.NET\Framework\
dir
现在你看到所有的目录和文件在。net \Framework\ Please,选择v…比如,最近去那里,
cd v4.0.30319
Run
csc
你会看到关于c#编译器版本的信息,这可以是类似的
Microsoft (R) Visual C# Compiler version 4.7.2556.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.