How .NET Works: CLR, IL, JIT and Assemblies

Dot NET Programming 10 min min read Updated: Nov 16, 2026 Beginner
How .NET Works: CLR, IL, JIT and Assemblies
Beginner Topic 4 of 5

From Code to Running Program

  1. You write C# source code (.cs files).
  2. The C# compiler (Roslyn) turns it into IL (Intermediate Language) stored in an assembly (.dll or .exe).
  3. When the program starts, the CLR (Common Language Runtime) loads the assembly.
  4. The JIT compiler converts IL into machine code for your CPU, just in time.
  5. The CPU runs the machine code.
Simple example: IL is like a recipe written in a universal language. The JIT is a cook who translates it for the local kitchen at the moment of cooking. That is why the same assembly runs on Windows, Mac and Linux.

The Main Parts

PartWhat it does
C# compiler (Roslyn)Checks your code and produces IL
CLRThe runtime: loads code, manages memory, handles exceptions and security
JITCompiles IL to fast machine code when needed
Garbage Collector (GC)Frees memory of objects you no longer use
BCL (Base Class Library)Built-in classes: strings, collections, files, networking, JSON
AssemblyThe compiled unit: a .dll library or .exe program

Managed Code and the Garbage Collector

In C# you create objects with new and never free them manually. The garbage collector finds objects that nothing refers to any more and releases their memory. This avoids a large class of memory bugs common in C and C++.

csharp void Work() { var list = new List<int> { 1, 2, 3 }; // memory allocated Console.WriteLine(list.Count); } // after this method, 'list' is unreachable and the GC can clean it up
Remember: The GC frees memory only. Things like files, database connections and sockets must be released by you, using using and IDisposable (we cover it in a later lesson).

Ways to Publish an App

ModeCommandNotes
Framework-dependentdotnet publish -c ReleaseSmall. The target computer must have the .NET runtime.
Self-containeddotnet publish -c Release --self-contained -r win-x64Includes the runtime. Larger but runs anywhere without install.
Native AOT<PublishAot>true</PublishAot>Compiled ahead of time. Fast startup, no JIT, with some limits.

Value Types and Reference Types (Preview)

Value typeReference type
Examplesint, double, bool, structstring, class, arrays
StoredDirectly in the variableObject on the heap, variable holds a reference
CopyCopies the valueCopies the reference

We use this idea throughout the course, and explain it again with examples in the OOP section.

Conclusion

C# compiles to IL, the CLR and JIT run it as machine code and the garbage collector manages memory. The BCL gives you thousands of ready classes.

Quick Summary: C# > IL > JIT > machine code. GC frees memory. BCL is the standard library.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators