Environment.Version 属性


获取一个 Version 对象,该对象描述公共语言运行时的主版本、次版本、内部版本和修订号。Gets a Version object that describes the major, minor, build, and revision numbers of the common language runtime.

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


用于显示公共语言运行时版本的对象。An object that displays the version of the common language runtime.


下面的示例显示公共语言运行时的版本。The following example displays the version of the common language runtime. (出于安全原因,示例输出中省略了版本。)(The version is omitted from the example output for security reasons.)

// Sample for the Environment::Version property
using namespace System;
int main()
   Console::WriteLine( "Version: {0}", Environment::Version );

This example produces the following results:
(Any result that is lengthy, specific to the machine on which this sample was tested, or reveals information that should remain secure, has been omitted and marked S"!---OMITTED---!".)

Version: !---OMITTED---!
// Sample for the Environment.Version property
using System;

class Sample
    public static void Main()
    Console.WriteLine("Version: {0}", Environment.Version.ToString());
' Sample for the Environment.Version property
Class Sample
   Public Shared Sub Main()
      Console.WriteLine("Version: {0}", Environment.Version.ToString())
   End Sub
End Class


对于 .NET Framework 版本 4、4.5、4.5.1 和 4.5.2,Environment.Version 属性返回字符串表现形式具有窗体 4.0.30319.xxxxxVersion 对象。For the .NET Framework Versions 4, 4.5, 4.5.1, and 4.5.2, the Environment.Version property returns a Version object whose string representation has the form 4.0.30319.xxxxx. 对于 .NET Framework 4.6 及更高版本,它的格式为 4.0.30319.42000For the .NET Framework 4.6 and later versions, it has the form 4.0.30319.42000.


对于 .NET Framework 4.5.NET Framework 4.5 和更高版本,不建议使用 @no__t 属性来检测运行时的版本;您可以通过查询注册表来确定公共语言运行时的版本。For the .NET Framework 4.5.NET Framework 4.5 and later, we do not recommend using the Version property to detect the version of the runtime; instead, you can determine the version of the common language runtime by querying the registry. 有关详细信息,请参阅如何:确定已安装的 .NET Framework 版本For more information, see How to: Determine Which .NET Framework Versions Are Installed.

有关随每个版本的 .NET Framework 一起安装的公共语言运行时版本的详细信息,请参阅版本和依赖项For more information about the version of the common language runtime that is installed with each version of the .NET Framework, see Versions and Dependencies.