Stage 1 · Lesson 6 of 7
Nullable reference types
NullReferenceException is the most common crash in .NET. make the compiler help. With <Nullable>enable</Nullable>, which every new template turns on, string means 'never null' and string? means 'may be null'.
The compiler then warns when you might use something that could be null without checking. Handle it with if (user is null), the ?. operator, which stops at a null, or ??, which supplies a fallback value. also allows customer?.Order = ... to assign only when the left side is not null.
Treat the warnings as errors from the first commit; fixing 300 of them later is miserable.
Common trapthe null-forgiving operator !, which silences a warning without fixing anything. Use it only when you can prove the value cannot be null.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- GuideFreeLearn C#
Microsoft · Beginner
Free official C# path: syntax, types, classes, collections and exceptions with in-browser exercises
- GuideFree.NET documentation
Microsoft
The official .NET docs: start with the CLI overview, project files and the C# language tour
Practise
Keep handy
Also worth your time
The features that ship with .NET 10: extension members, the field keyword and null-conditional assignment
Object-oriented design worked through on real systems: classes, relationships and responsibilities
- Refactoring.Guru: Design PatternsGo deeper
Free: the classic design patterns explained with diagrams and C# examples