I am Utpal Vishwas from Uttar Pradesh. Have completed my B. Tech. course from MNNIT campus Prayagraj in 2022. I have good knowledge of computer networking.
Sure, here is how to detect Windows version in .NET:
C#
using System;
namespace DetectWindowsVersion
{
class Program
{
static void Main(string[] args)
{
// Get the Windows version.
var windowsVersion = Environment.OSVersion;
// Print the Windows version.
Console.WriteLine("Windows version: {0}", windowsVersion.VersionString);
}
}
}
This code will first get the Windows version from the Environment object. The
Environment object provides information about the environment that the code is running in.
Next, the code will print the Windows version to the console. The VersionString property of the
OSVersion class returns a string that represents the Windows version.
Here is an example of the output of this code:
Windows version: 10.0.19043.1237
This output shows that the computer is running Windows 10, version 20H2.
Here is a table summarizing the key properties of the OSVersion class:
Property
Description
Version
The Windows version number.
MajorVersion
The major version number of Windows.
MinorVersion
The minor version number of Windows.
BuildNumber
The build number of Windows.
Revision
The revision number of Windows.
VersionString
A string that represents the Windows version.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Sure, 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: