Environment.OSVersion Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
The platform identifier and version number.
This property was unable to obtain the system version.
-or-
The obtained platform identifier is not a member of PlatformID
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.
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: