My question is as easy as it seems: I want to find out which version of C# I'm 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'm 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'm 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 i.e.
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:\Windows\Microsoft.NET\Framework\v4.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
C# 7.3 is released with .NET 4.7.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.
The C# version you are using totally depends upon the .Net version you are using.
if you are using visual studio for development, you get to choose the .net framework version the c# version associated with it comes accordingly
These are the versions of C# known:
- 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
DisposeonIEnumerators which implementedIDisposable. 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.
Refrence Jon Skeet's C# Versions Answer
.NET version through registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\ explore the children and look into each version. The one with key 'Full' is the version on the system.
https://support.microsoft.com/en-us/kb/318785 https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx
.NET version through Visual Studio
Help -> About Microsoft Visual Studio -> The .NET version is specified on the top right.
As I understand at this time the Visual studio uses .NET Framework from the OS.
The target .NET Framework version of a project in Visual Studio can be modified with Project Properties -> Application -> Target Framework
Through the dll
If you know the .NET Framework directory e.g. C:\Windows\Microsoft.NET\Framework64\v4.0.30319
Open System.dll, right click -> properties -> Details tab
C# version
Help -> About Microsoft Visual Studio
In the installed products lists there is Visual C#. In my case Visual C# 2015
Visual Studio (Microsoft) ships C# by name Visual C#.
https://msdn.microsoft.com/en-us/library/hh156499.aspx
C# 6, Visual Studio .NET 2015 Current version, see below
By default following are corresponding version of C# compilers for Visual Studio:
- Visual Studio 2015: C# 6.0
- Visual Studio 2013: C# 5.0
- Visual Studio 2012: C# 5.0
- Visual Studio 2010: C# 4.0
- Visual Studio 2008: C# 3.0
- Visual Studio 2005: C# 2.0
- Visual Studio.NET 2003: C# 1.2
- Visual Studio.NET 2002: C# 1.0
You can also modify version please follow below steps.
Open the project properties window:
step 1. Right click on the Project Name
step 2. Select "Properties" (last option in menu)
step 3. Select "Build" from left hand side options and scroll till down
step 4. click on "Advance" button.
step 5. It will open a popup and there you will get "Language Version" dropdown
step 6. Select desired version of C# and Click "OK"
In order to see the installed compiler version of VC#:
Open Visual Studio command prompt and just type csc then press Enter.
You will see something like following:
Microsoft (R) Visual C# Compiler version 4.0.30319.34209
for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.
P.S.: "CSC" stand for "C Sharp Compiler". Actually using this command you run csc.exe which is an executable file which is located in "c:\Windows\Microsoft.NET\Framework\vX.X.XXX". For more information about CSC visit http://www.file.net/process/csc.exe.html
For Windows, you run dev at the command/ search program line and select Developer Command Prompt for VS. Then you are going to just run
csc
Now you get information similar to
Microsoft (R) Visual C# Compiler version 2.6.0.62329 (5429b35d)
Copyright (C) Microsoft Corporation. All rights reserved.
For Windows and if you start with cmd terminal
cd C:\Windows\Microsoft.NET\Framework\
dir
Now you see all directories and files in .NET\Framework\ Please, select v... latest and go there, for example,
cd v4.0.30319
Run
csc
You will see information about version of C# compiler, that can be something similar to
Microsoft (R) Visual C# Compiler version 4.7.2556.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.
From developer command prompt type
csc -langversion:?
That will display all C# versions supported including the default:
1
2
3
4
5
6
7.0 (default)
7.1
7.2
7.3 (latest)
If you are using VS2015 then follow below steps to find out the same:
- Right click on the project.
- Click on the Properties tab.
- From properties window select Build option.
- In that click on the Advance button.
- There you will find out the language version.
Below images show the steps for the same:
Step 1:
Step 2:
来源:https://stackoverflow.com/questions/19532942/which-version-of-c-sharp-am-i-using


