Member-only story
C# Compiler in 2 Minutes
How C# compilation works, easy to understand
4 min readOct 19, 2023

Before we continue; This is a 4 minutes read and I would highly encourage everyone to read the whole article, but for TLDR; Head over to The Compilation Process.
So, C# compiler is the bridge that transforms your high-level C# code into a format that your computer understands. But how does this transformation occur? Let’s dive in!
Understanding the Basics
- What is a Compiler?
A compiler is like a translator. Imagine you’re speaking English, but your friend only understands French. You’d need a translator to convey your message. Similarly, a compiler translates high-level programming languages into machine code. - Why C# Needs a Compiler:
C# is a high-level language, meaning it’s closer to human language than machine language. For your computer to execute C# code, it needs to be in a format it comprehends, and that’s where our compiler steps in.
The Compilation Process
- Writing the Code:
As a developer, you start by writing your C# code. This is the high-level language that you and other developers can easily understand. - Compilation to IL:
Once you’re ready to build or compile your project, the C# compiler comes into play. It takes your high-level C# code and translates it into Intermediate Language (IL). IL is a lower-level, platform-agnostic representation of your code. Think of it as a “universal language” that can be understood by any .NET-compatible platform. - Storing the IL:
This IL code is then stored in a file, typically with a .dll or .exe extension, depending on whether you’re building a library or an executable application. This file is saved on your disk and is ready to be executed or used by other programs. - Execution Time — JIT Compilation:
When you decide to run your application, the IL isn’t directly executed by your machine’s processor. Instead, another crucial player enters the scene: the Just-In-Time (JIT) compiler. The JIT compiler takes the IL code and translates it into machine code, a language that your computer’s processor understands. - Why JIT?
The beauty of JIT compilation is its “on-the-fly” nature…