C#: From Basics to Expert
Four levels, twelve lessons, every example compiled and run on .NET
C# is Microsoft's general-purpose language and the one most .NET applications are written in: web services, desktop software, games through Unity, and a large amount of enterprise back-end work.
Overview
.NET has been cross-platform and open source for years now, so none of this is tied to Windows. If you have avoided it on that basis, the basis is gone.
Introduction
No C# is assumed. The course is taught on .NET 8 and C# 12, so it teaches the language as it is now rather than as it was: nullable reference types, records, pattern matching and channels are treated as ordinary tools, because in current code they are.
Three lessons and a Level Check quiz per level, finishing with an Expert Exam. There is no in-browser C# runner on the site yet, so every example was compiled and run on a real .NET SDK before publication, with the build's own warnings treated as failures - install the SDK from dotnet.microsoft.com and run each one with dotnet run, or paste it into a scratch project.
Every example in this course was compiled and run on a real .NET SDK before publication, with the build's own warnings treated as failures. There is no in-browser C# runner yet, so the code blocks are for reading and for running in your own editor.
There is no in-browser runner for this language on the site, so to follow along install the SDK from dotnet.microsoft.com and run each one with dotnet run, or paste it into a scratch project.
By the end you will be able to write C# that holds up under review: nullability annotations the compiler can actually check, records and structs chosen deliberately, LINQ whose execution you can predict, async code that does not deadlock, and disposal that happens even when something throws.
What you will be able to do
- Say what a variable holds, and why that decides so much
- Use nullable reference types deliberately, and ! almost never
- Choose between class, struct and record for a reason you can state
- Explain what await frees, and why async void is a trap
- Read a LINQ query and know when it has not run yet
- Find a leak by asking what still holds a reference
What each level covers
4 levels · 16 lessons
-
Level 1 - Basic
The ground rules. Value types against references, which decides what a copy means; nullable reference types, the feature that turns a NullReferenceException into a compiler warning if you let it; control flow with pattern switches; and the collections, with LINQ over them introduced early because it is how C# code reads.
4 lessons 43 min of reading
Start with Values, Types and Nullable Reference Types → -
Level 2 - Intermediate
Shaping data and admitting failure. Classes, structs and records, and the question of which is right, with init and required properties; interfaces, reified generics, variance and extension methods; and exceptions, disposal and the using statement, which is the part people skip and then leak a file handle over.
4 lessons 49 min of reading
Start with Classes, Structs and Records → -
Level 3 - Advanced
Concurrency and expression. async and await, and what they actually free - which is a thread, not time; LINQ in depth, including deferred execution and the moment a query runs; and real parallelism with locks, Interlocked and channels, where the hard part is never the syntax.
4 lessons 52 min of reading
Start with async, await and Tasks → -
Level 4 - Expert
The runtime, and the shape of an application. Memory, the heap and disposal, including the leaks a garbage collector cannot prevent; where the time and the allocations go, found by measurement; and how to arrange a solution so that a change stays small and the dependencies run in one direction.
4 lessons 59 min of reading
Start with Memory, the Heap and Disposal →
Guides and articles
Longer reading about this subject, written alongside the course.
Before you start
- No prior C#
- Some experience of any programming language helps but is not required
Common questions
- What does the C#: From Basics to Expert course cover?
- It is 4 levels and 16 lessons: Level 1 - Basic; Level 2 - Intermediate; Level 3 - Advanced; Level 4 - Expert. Each level ends with a quiz, and the last one is an exam over the whole course.
- How long does it take?
- About 203 minutes of reading and exercises - roughly 3.4 hours. It is self-paced with no cohort and no start date, so you can leave and come back and the site remembers where you were.
- What do I need to know first?
- No prior C#. Some experience of any programming language helps but is not required.
- Is it free?
- Yes. Every lesson, example and quiz in this course is free to read, and you do not need an account to read them. Signing in only adds progress tracking and quiz results.
- What will I be able to do afterwards?
- Say what a variable holds, and why that decides so much. Use nullable reference types deliberately, and ! almost never. Choose between class, struct and record for a reason you can state. Explain what await frees, and why async void is a trap. Read a LINQ query and know when it has not run yet. Find a leak by asking what still holds a reference.