Using C#, what is the best way to ask the .NET Runtime which version you are running under?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
Use
Environment.Version
. This has the version number of the CLR currently running your code and is supported on all versions of the CLR.Documentation
You can write a simple method for this purpose:
The output is your .net version.
You can also find the installed versions in the following location:
If you are using Visual Studio, run Visual Studio commander from the start menu, and enter
clrver
, and it gives you the running version.And for sure, you can always check your registry for that:
It is important to be careful about asking which version of the framework is running, and which version of the runtime is running, as they can be different. Your title and body ask subtly different questions.
@JaredPar is right on the money with the runtime version.
For framework versions, check out this closely-related post: How to detect what .NET Framework versions and service packs are installed?