18/02/2025
The C # compiler (named Roslyn) used by the dotnet CLI tool converts your C # source code
into intermediate language (IL) code and stores the IL in an assembly (a DLL or EXE file). IL code
statements are like assembly language instructions, which are executed by .NET’s virtual machine,
known as CoreCLR, the newer name for the Common Language Runtime (CLR) in modern .NET. The
legacy .NET Framework has a CLR that is Windows-only, and modern .NET has one for each OS, like
Windows, macOS, and Linux. These days, they are all commonly referred to as CLRs.
At runtime, CoreCLR loads the IL code from the assembly, the just-in-time (JIT) compiler compiles it into
native CPU instructions, and then it is executed by the CPU on your machine.
The benefit of this two-step compilation process is that Microsoft can create CLRs for Linux and macOS,
as well as for Windows. The same IL code runs everywhere because of the second compilation step,
which generates code for the native operating system and CPU instruction set.
Regardless of which language the source code is written in (for example, C #, Visual Basic, or F #), all .NET
applications use IL code for their instructions stored in an assembly.
So, the compilation process typically involves translating source code into IL, which is then compiled into
machine code at runtime by the CLR using JIT compilation.