What Common Language Runtime in C#

CLR is a run time environment in which program written in C# and other .net language areexecuted it also support cross language interoperability.

CLR provides a number of services that includes

  1. Loading and execution of program memory isolation for application.
    1. Verification of type safety compilation of IL into native executable code
    1. Providing metadata.
    1. Memory management (automatic garbage collection).
    1. Enforcement of security.
    1. Interoperability with other systems.
    1. Managing exceptions and errors.

Components of CLR

1 Common Type System

2. Common Language Specification

3. Microsoft intermediate language

4. Managed code

1 Common Type System

The .net framework provides multiple language support using the feature known as commontype system that is built into the CLR.The CTS supports variety of types and operations foundin most programming languages and therefor calling one language from another does notrequire type conversion.

Although C# is specially designed for the .NET platform we can build .NET programs in anumber of other languages including c++ and visual basic.

2. Common language specification:-

Common language specification the common language on the .NET platform these rules serveas a guide to third party compiler designers and library builders.

The CLS is a subset of CTS and therefore the languages supporting the CLS can use eachother’s class libraries as if they are there on application program interfaces that are designedfollowing the rules of CLS can easily be used by all the .NET languages.

Microsoft intermediate language:-

MSIL is an instruction set into which all the .NET programs are compiled. It is similar to assemblylanguages and contents instructions for loading, storing, initializing and calling methods.

when we compile C# program or any program written in a CLS complaint language the sourcecode iscompiled into MSIL.

Managed code:-

As we know the CLR is responsible for managing the execution of code compiled for the .NETplatform thecode that satisfies the CLR at run time in order to execute is referred to as managed code. Compilers thatare compatible to the .NET platform generate managed code.

For example C# compiler generates managed code. The managed code generated by C# is IL.IL code thenconverted to native machine code by the JIT compiler.

Posted In : ,

Leave a Reply

Your email address will not be published. Required fields are marked *