Environment.Version 屬性


取得描述通用語言執行平台的主要、次要、組建 (Build) 和修訂編號的 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


顯示 Common Language Runtime 版本的物件。An object that displays the version of the common language runtime.


下列範例會顯示 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 屬性會傳回 Version 物件,其字串表示的格式為 4.0.30319.xxxxxFor 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 和更新版本中,我們不建議使用 Version 屬性來偵測執行時間的版本。相反地,您可以藉由查詢登錄來判斷 common language runtime 的版本。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 版本一起安裝之 common language runtime 版本的詳細資訊,請參閱版本和相依性。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.