What is Common Language Runtime in C#

Today in this article I will explain the very basic and starting topics of the C# programming language because if the basics are strong then you will survive the future of programming. It is very necessary to understand how programs are compiled and run in the Microsoft .NET Framework. Let's start it.


  • As part of the Microsoft  .NET Framework, the Common Language Runtime (CLR) is the programming (Virtual Machine component) that manages the execution of programs written in any language that uses the .NET Framework, for example C#, VB.Net, F# and so on.
  • Programmers write code in any language, including VB.Net, C# and F# yhen they compile their programs into an intermediate form of code called CLI in a portable execution file (PE) that can be managed and used by the CLR and then the CLR converts  it into machine code to be will executed by the processor.
  • The information about the environment, programming language, its version and what class libraries will be used for this code are stored in the form of metadata with the compiler that tells the CLR how to handle this code.
  • The CLR allows an instance of a class written in one language to call a method of the class written in another language.

Got it? I will make this easier by making an entire picture of this.

If you can visualize the concept then the understanding will be easy.


CLR Diagram

Functions of the CLR

  • Convert code into CLI.
  • Exception handling
  • Type safety
  • Memory management (using the Garbage Collector)
  • Security
  • Improved performance
  • Language independency
  • Platform independency
  • Architecture independency

Components of the CLR

  • Class Loader

    Used to load all classes at run time.
  • MSIL to Native code

    The Just In Time (JTI) compiler will convert MSIL code into native code.
  • Code Manager

    It manages the code at run time.
  • Garbage Collector

    It manages the memory. Collect all unused objects and deallocate them to reduce memory.
  • Thread Support

    It supports multithreading of our application.
  • Exception Handler

    It handles exceptions at run time.