Upraviť

Zdieľať cez


Environment.OSVersion Property

Definition

Gets the current platform identifier and version number.

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

Property Value

The platform identifier and version number.

Exceptions

This property was unable to obtain the system version.

-or-

The obtained platform identifier is not a member of PlatformID

Remarks

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 and later versions, Environment.OSVersion returns the actual OS version in compatibility modes specified by the application manifest. 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