How to Detect the Windows version in .NET?
How to Detect the Windows version in .NET?
564
13-Jul-2023
Aryan Kumar
14-Jul-2023Sure, here is how to detect Windows version in .NET:
C#
This code will first get the Windows version from the
Environmentobject. TheEnvironmentobject provides information about the environment that the code is running in.Next, the code will print the Windows version to the console. The
VersionStringproperty of theOSVersionclass returns a string that represents the Windows version.Here is an example of the output of this code:
This output shows that the computer is running Windows 10, version 20H2.
Here is a table summarizing the key properties of the
OSVersionclass: