As a literal answer to the question new-ish [ update: roslyn versions above 2, see comment from Cameron MacFarland ], csc versions have a version / version switch
c:\>csc /version 2.3.2.62116 (8522b473)
For scripting (if you want to include a version), testing %errorlevel% of csc /version might be enough to put in an too old bucket.
/version , however, DOES NOT appear in https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/listed-alphabetically (which seems to be the newest version), and I can not find what or in the list on which version was added.
UPDATE: I would also be very careful with the version number reported by csc, for example, my personal 'default' is in C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn and has version 2.3.2.62116 (and file date 22/9/2017), but I also have C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe with version 4.7.2046.0 (and file date 18/03 / 2017) (and which does not accept the / version switch).
So, in response to
Is there any command to get the C # compiler version?
I would say yes, perhaps sometimes, but I would consider this version with a pinch of salt. Looking at the version stamps, I have a version representing the FIle version of the csc.exe assembly, which seems to come out of the โlarger entityโ version that compiled csc, and there are at least incompatible numbering schemes for Rosyln compilers and "Traditional."
source share