I’d like to know what version of C# I’m using. If I were to use Python, I would type python -V or something similar from the command line.
import sys print sys.version
I’d do something like this in PHP: In PHP, phpinfo() is used; in Java, java -version is used.
However, I was unable to locate a way to accomplish this in C#.
Although the name suggests otherwise, this question does not provide an answer.
I understand that it is dependent on the.NET framework, but is there a way to determine my framework programmatically? I don’t mean without examining the names of my.NET folders in the directory.
Asked by Salvador Dali
It depends on whatever version of the.NET Framework you’re using. Check Jon Skeet’s answer about Versions.
The following is a condensed version of his response.
Answered by Praveen
While this isn’t directly answering your query, I’m including it because this page came up #1 in my searches when I was seeking for this information.
If you’re using Visual Studio, right-click on your project and select Properties -> Build -> Advanced from the drop-down menu. This should include a list of available versions as well as the one your project is currently utilizing.
Answered by Darth
To find the framework’s version, look at the version of one of the key assemblies, e.g.
Getting the version of the C# compiler is a little more difficult, but you should be able to guess it by looking at the framework version.
If you’re using the command line compiler (csc.exe), you can look up the version in the help (you’ll also need to know the Framework version:
C:\Windows\Microsoft.NET\Framework\v4.0.30319>csc /? Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Answered by Alexei Levenkov
Type from the developer command prompt
This will show all supported C# versions, including the default:
1 2 3 4 5 6 7.0 (default) 7.1 7.2 7.3 (latest)
Answered by fortesl
The majority of the responses are right. I was only consolidating three, which I found to be simple and quick. Also, in VS2019, #1 is no longer possible.
More advice can be found here.
Answered by San
Post is based on https://stackoverflow.com/questions/19532942/which-version-of-c-sharp-am-i-using