C# ships a new version every year, and most of what arrives is small: a shorter way to write something you could already write. That makes the language pleasant to follow and slightly awkward to learn, because the answer to “how do I do X” depends on which version you are on.
This page has both halves. The first sections are the language as it stands: types, variables, control flow, pattern matching. The later ones go version by version, so you can see what a feature replaced and decide whether it is worth the upgrade.
Nothing here assumes you have written C# before. If you have, start at the version sections and work backwards.
Starting Out
Setting up, and the vocabulary the rest of the page assumes.
- Data Types, Declarations and Variable Definitions
- Differences Between .NET and C#
- Introduction to .NET and C# – Differences, Structure, SDK, Runtime, Compilation
- Setting Up the Development Environment
Control Flow
Loops, conditions and the pattern matching that has quietly replaced a lot of both.
- Switch Expression With Multiple Cases
- Break and Continue Statements
- While, For, Do-While Loops
- Pattern Matching
- Conditions in C# with If-Else, and Switch-Case Statements
- Comparing for and foreach Loops
Types, Conversions and Comments
Converting between types, and the comment styles C# actually uses.
What Each Version Added
Version by version. Each article shows the code the feature replaces, which is the fastest way to judge whether you want it.
- Top-Level Statements
- Required Members
- File-Scoped Types in C# 11
- Global Using Directives
- New Features in C# 12
- File Access Modifier
- C# 10 New Features
- Improvements in the using Directive
- How to Use Interceptors in C# 12
Checking and Setting the Version
Finding out which version you are on, and telling a whole solution to use a different one.
- Set C# Language Version for All the Projects in a Solution
- How to Determine .NET Version Programatically
Where to Go Next
Once the syntax is familiar, these are the next things to learn:
You do not have to adopt a feature because it is new. The ones worth taking early are the ones that remove a whole category of mistake, and the articles below say which those are.
