Environment.OSVersion Property

Definition

Gets an OperatingSystem object that contains the current platform identifier and version number.

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

Property Value

OperatingSystem

An object that contains 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

The Environment.OSVersion property does not provide a reliable way to identify the exact operating system and its version. Therefore, we do not recommend that you use this method. Instead:

  • To identify the operating system platform, use the RuntimeInformation.IsOSPlatform method.

  • Avoid writing code that depends on a reported operating system version. Instead, check for the availability of the features that your application needs.

Applies to