Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which version of C# am I using

Tags:

c#

version

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 released with .NET 4.6.2

C# 7.3 released with .NET 4.7.2

C# 8.0 released with NET Core 3.0

C# 9.0 released with NET 5.0

C# 10.0 released with NET 6.0


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 -> Properties -> Build -> Advanced This should list available versions as well as the one your proj is using.

enter image description here


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

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)

Most of the answers are correct above. Just consolidating 3 which I found easy and super quick. Also #1 is not possible now in VS2019.

  1. Visual Studio: Project > Properties > Build > Advanced
    This option is disabled now, and the default language is decided by VS itself. The detailed reason is available here.

  2. Type "#error version" in the code(.cs) anywhere, mousehover it.

  3. Go to 'Developer Command Prompt for Visual Studio' and run following command. csc -langversion:?

Read more tips: here.