which version of C# am I using

My question is as easy as it seems: I want to find out which version of C# I am using. If I would be using python I would do something like python -V from command line, or type

import sys
print sys.version

In php I would do something like this: phpinfo(); in java: java -version

But I was not able to find how to achieve this in C#.

I am completely new to C#, so please do not beat me too hard. What surprises me that I was not able to find this answer on SO, therefore I think that I am missing something or bad in finding things. BTW, this question does not answer it, although the name suggests that it should.

Thank you for answers. Right now I got that it depends on .NET framework, but is there a programmatic way of figuring out my framework? (without going to the directory and checking the name of my .NET folders)


To get version of framework - look at version of one of main Assemblies ie

 Console.Write(typeof(string).Assembly.ImageRuntimeVersion);

Getting version of C# compiler is somewhat harder, but you should be able to guess version by checking what framework version is used.

If you are using command line compiler (csc.exe) you can check help to see version (also you'd need to know Framework version anyway:

C:WindowsMicrosoft.NETFrameworkv4.0.30319>csc /?
Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1

It depends upon the .NET Framework that you use. Check Jon Skeet's answer about Versions.

Here is short version of his answer.

C# 1.0 released with .NET 1.0

C# 1.2 (bizarrely enough); released with .NET 1.1

C# 2.0 released with .NET 2.0

C# 3.0 released with .NET 3.5

C# 4.0 released with .NET 4

C# 5.0 released with .NET 4.5

C# 6.0 released with .NET 4.6

C# 7.0 is released with .NET 4.6.2


While this isn't answering your question directly, I'm putting this here as google brought this page up first in my searches when I was looking for this info.

If you're using Visual Studio, you can right click on your project, go to project properties and see the version your project is using by going to 'advanced' on the 'build' tab. This should list available versions as well as the one your proj is using.

在这里输入图像描述

链接地址: http://www.djcxy.com/p/21314.html

上一篇: 自定义app.config部分包含一个简单的“添加”元素列表

下一篇: 我正在使用哪个版本的C#