Environment.Version プロパティ

定義

共通言語ランタイムのメジャー、マイナー、ビルド、リビジョンの番号で構成されるバージョンを取得します。

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

プロパティ値

共通言語ランタイムのバージョン。

次の例では、共通言語ランタイムのバージョンを表示します。

// 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
open System

printfn $"\nVersion: {Environment.Version}"
' 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 Core 3.x および .NET 5 以降の場合、 プロパティは Environment.Version .NET ランタイムのバージョン番号を返します。

.NET Framework バージョン 4、4.5、4.5.1、および 4.5.2 の場合は、Environment.Version プロパティから返される Version オブジェクトの文字列表現が 4.0.30319.xxxxx という形式になっています。 .NET Framework 4.6 以降のバージョンと 3.0 より前の .NET Core バージョンでは、 という形式4.0.30319.42000になります。

警告

.NET Framework 4.5 以降では、 プロパティをVersion使用してランタイムのバージョンを検出することはお勧めしません。代わりに、レジストリのクエリを実行して共通言語ランタイムのバージョンを確認できます。 詳細については、「方法: インストールされている.NET Frameworkバージョンを確認する」を参照してください。

各バージョンの.NET Frameworkと共にインストールされる共通言語ランタイムのバージョンの詳細については、「バージョンと依存関係」を参照してください。

適用対象