Environment.OSVersion Property


Gets the current platform identifier and version number.

 static property OperatingSystem ^ OSVersion { OperatingSystem ^ get(); };
public static OperatingSystem OSVersion { get; }
member this.OSVersion : OperatingSystem
Public Shared ReadOnly Property OSVersion As OperatingSystem

Property Value


The platform identifier and version number.


This property was unable to obtain the system version.


The obtained platform identifier is not a member of PlatformID


In .NET versions prior to .NET 5.0, Environment.OSVersion returns an OS version that may be incorrect when an application runs under Windows compatibility mode. For more information, see GetVersionExA function remarks. In .NET 5.0 and later, Environment.OSVersion always returns the actual OS version. For more information, see Environment.OSVersion returns the correct operating system version.

To identify the operating system platform, for example, Linux or Windows, you can use the RuntimeInformation.IsOSPlatform method.

Applies to