Environment.Version 屬性

定義

取得包含主要版本、次要版本、組建與 Common Language Runtime 修訂編號的版本號碼。Gets a version consisting of the major, minor, build, and revision numbers of the common language runtime.

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

屬性值

Version

Common language runtime 的版本。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();
   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();
    Console.WriteLine("Version: {0}", Environment.Version.ToString());
    }
}
' Sample for the Environment.Version property
Class Sample
   Public Shared Sub Main()
      Console.WriteLine()
      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.

適用於