C# vs .NET vs the CLR: How C# Code Runs
Codevity Admin · 10/25/2026
Step 2 of 31 · C# Interview Preparation for Beginners · Stage 2: Language fundamentals
Codevity Admin · 10/25/2026
"What is the difference between C# and .NET?" is often the very first question. The short answer: C# is the language you write. .NET is the platform that runs it.
C# is a modern, object-oriented, type-safe programming language. .NET is the developer platform that provides the runtime, the base class library and the tools needed to build and run applications. The C# compiler turns your code into an intermediate form, and the .NET runtime turns that into machine code while the program runs.
Program.cs --(Roslyn compiler)--> Program.dll --(CLR + JIT)--> machine code --> your OS
(C# source) (IL + metadata) (runs natively)Program.cs)..dll or .exe).Because the output is IL, not machine code, the same assembly runs on Windows, Linux and macOS, as long as the right .NET runtime is installed. Modern .NET can also precompile ahead of time (ReadyToRun or Native AOT) to start faster.
| Term | What it is |
|---|---|
| C# | The programming language: syntax, keywords and compiler rules |
| Roslyn | The open-source compiler that turns C# (and VB.NET) into IL |
| IL | The CPU-independent intermediate language inside every assembly |
| CLR | The runtime that executes IL: JIT compiler, garbage collector, type system, threading |
| JIT | The part of the CLR that compiles IL to machine code at run time |
| BCL | The Base Class Library: System.Collections.Generic, System.IO, System.Linq, System.Text.Json and more |
| .NET SDK | The tools to build apps (compiler, dotnet CLI, templates). The runtime is the smaller package needed only to run them |
| Assembly | The compiled unit of deployment: a .dll or .exe |
Managed code runs under the CLR, which handles memory and safety for you. Unmanaged code (native C or C++ libraries, operating system APIs) runs outside the CLR, so you manage its resources yourself, for example with .
Keywords such as , and are C# names for types in the base class library: , and .
The first line prints the runtime you are using. The next two show that and are the same type, and that is just a friendlier name for .
| .NET Framework (1.0 to 4.8.1) | Modern .NET (5 and later, currently .NET 10) | |
|---|---|---|
| Platforms | Windows only | Windows, Linux, macOS, and mobile through MAUI |
| Source | Largely closed | Open source |
| Packaging | One machine-wide installation, tied to Windows updates | Side by side. Each app can ship or pick its version |
| Focus | Maintained for existing applications | Active development, built for cloud and containers |
New projects should use modern .NET. Releases alternate: the even-numbered ones (6, 8, 10) are long-term support.
IDisposableintstringboolSystem.Int32System.StringSystem.BooleanintInt32stringSystem.StringConsole.WriteLine(Environment.Version);dotnet build.dllbinusing System.Runtime.InteropServices;
Console.WriteLine(RuntimeInformation.FrameworkDescription); // for example: .NET 10.0.0
Console.WriteLine(typeof(int) == typeof(Int32)); // True
Console.WriteLine(typeof(string).FullName); // System.String