Environment.OSVersion 属性


获取包含当前平台标识符和版本号的 OperatingSystem 对象。Gets an OperatingSystem object that contains 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


一个包含平台标识符和版本号的对象。An object that contains the platform identifier and version number.


此属性不能获得系统版本。This property was unable to obtain the system version.

- 或 --or- 获得的平台标识符不是 PlatformID的成员The obtained platform identifier is not a member of PlatformID


Environment.OSVersion 属性不提供可靠的方法来确定确切的操作系统及其版本。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:

  • 若要确定操作系统平台,请使用 RuntimeInformation.IsOSPlatform 方法。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.