Lezen in het Engels Bewerken

Delen via


Environment.Version Property

Definition

Gets a version consisting of the major, minor, build, and revision numbers of the common language runtime.

public static Version Version { get; }

Property Value

The version of the common language runtime.

Examples

The following example displays the version of the common language runtime.

// Sample for the Environment.Version property
using System;

class Sample
{
    public static void Main()
    {
    Console.WriteLine();
    Console.WriteLine("Version: {0}", Environment.Version.ToString());
    }
}

Remarks

For .NET Core 3.x and .NET 5+, the Environment.Version property returns the .NET runtime version number.

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. For the .NET Framework 4.6 and later versions, and .NET Core versions before 3.0, it has the form 4.0.30319.42000.

Waarschuwing

For the .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. For more information, see How to: Determine Which .NET Framework Versions Are Installed.

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.

Applies to

Product Versies
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1