get system release in csharp

To get the system release/version in C#, you can use the Environment.OSVersion property. Here's an example:

main.cs
OperatingSystem os = Environment.OSVersion;
Console.WriteLine($"Current OS: {os.Version}");
92 chars
3 lines

The Environment.OSVersion property returns an OperatingSystem object, which contains various properties related to the current operating system version. The Version property gives you the version number.

Note that the version number is represented as a Version object, which has Major, Minor, Build, and Revision properties. You can access these individually if needed, or simply display the entire Version object as shown above.

gistlibby LogSnag