C# vs .NET: What Is the Difference?
By the end of this lesson
Explain the relationship between the language, the runtime, the SDK and the libraries.
These two names get used interchangeably and they are not the same thing. Sorting this out early prevents a lot of confusion later, particularly around installation and deployment.
- C#
- The language. Its rules of grammar: keywords, syntax, what is and is not valid. C# alone cannot do anything — it needs something to run on.
- .NET
- The platform your C# runs on. It includes the runtime that executes your compiled code, a large library of ready-made building blocks, and the tooling that builds and publishes your work.
An analogy that holds up reasonably well: C# is the language you write instructions in, and .NET is the workshop with the tools and materials. You can describe a chair in English, but you need the workshop to build one.
The parts of .NET you will actually meet
- Runtime
- Executes your program. Handles memory, and turns the compiled intermediate code into instructions for the machine it is on. A machine that only runs applications needs this.
- SDK
- The software development kit. Includes the compiler, the dotnet command-line tool, and the runtime. A machine that builds applications needs this. On your own computer, install the SDK.
- Base class library
- The ready-made building blocks: collections, file access, HTTP clients, date handling, JSON. Most of what you use day to day comes from here rather than from the language itself.
// Language: foreach, string, var are C# syntax
// Library: List<T>, Console, DateTime come from .NET
List<string> tasks = new List<string> { "Review PR", "Deploy" };
foreach (string task in tasks)
{
Console.WriteLine($"{DateTime.UtcNow:HH:mm} - {task}");
}- foreach and string are part of the language — they are grammar.
- List, Console and DateTime are types supplied by .NET. They could in principle be replaced; the language keywords could not.
- In practice you rarely need to think about the boundary, but knowing it exists explains why documentation is split the way it is.
Which do you need on a given machine?
| Your development machine | A server running your app | |
|---|---|---|
| Install | SDK | Runtime (or a self-contained build) |
| Can compile code | Yes | No |
| Can run compiled code | Yes | Yes |
| Size | Larger | Smaller |
Summary
- C# is the language; .NET is the platform it runs on
- The SDK builds code and includes the runtime; the runtime only executes it
- Install the SDK on development machines
- Most types you use daily come from the .NET library rather than the language itself
Practice
Attempt each one before opening the solution. Getting it wrong first is how the idea sticks.
Think about it
Think about it
A container image used to run an application in production is built from a runtime base image, not an SDK image, while the build stage uses the SDK. Why is that split worth making?
Show solution
The compiler is only needed to produce the application, not to run it. Shipping the SDK to production makes the image substantially larger for no benefit, and includes tooling that has no reason to exist on a running server.
This is exactly what a multi-stage Docker build does, and the Docker course covers it directly.
Knowledge check
Nothing is recorded and there is no score. The explanation appears either way.
Saved in this browser only.