Thursday, April 07, 2011

Getting the CLR Version

The .NET common language runtime (CLR) is the run-time environment that executes managed code developed in .NET languages such as C# and Visual Basic. The version of the CLR varies for different versions of the .NET framework.

Common Language Runtime
The common language runtime (CLR) is a core part of the .NET framework. It is responsible for executing managed code created using languages such as C# or Visual Basic, which has then been compiled to intermediate language (IL). The CLR provides many services, including memory management and garbage collection.

Sometimes you will want to know which version of the CLR is executing your .NET program. You can obtain the version number by reading the static Version property of the Environment class. This property returns a Version object. It can be converted to a string for output purposes or the four sections of the version number can be read individually using the Major, Minor, Build and Revision properties.

Console.WriteLine(Environment.Version);

Read more: BlackWasp