Skip to content
BENIBIX Learn

Common Language Runtime (CLR)

Development⚙️ Compilers & RuntimesRuntimes

Also known as CLR, .NET Runtime, Managed Code Runtime

The .NET runtime. It runs C#, F# and Visual Basic code as one kind of code.

Think of it like

It is like a helper at a big meeting. People speak in many ways, and she puts it all in one.

Example

A team writes one part of an app in C# and one in F#. Both compile to CIL, and the CLR runs them as one program.

Why it matters

It is the engine under each .NET app, from websites to Windows tools. It is also how .NET languages work together.

Definition

The Common Language Runtime, or CLR, is the runtime that runs .NET programs. Tools for C#, F# and Visual Basic turn code into an in-between code called CIL. When the program runs, the CLR turns CIL into machine code, just in time. It also cleans up memory with garbage collection. Code run this way is called managed code.

Example code

console
$ dotnet new console -o Hello
$ dotnet run --project Hello
Hello, World!
The dotnet tool builds a C# app, and the CLR runs it.
The CLR sits on the bottom path too. It turns CIL into machine code as the program runs.

Common mistake

Mixing up the CLR and C#. C# is a language; the CLR is the runtime that runs what it compiles to.

Key takeaways

  1. 1
    Runs CIL. The code .NET languages compile to.
  2. 2
    Many languages. C#, F# and Visual Basic share it.
  3. 3
    Managed code. It handles memory for you.

Compare