.NET developer

Stage 1 · Lesson 6 of 7

Nullable reference types

C# and the .NET platform

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

  • GuideFree
    Learn 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

  • The free C# track: small exercises with mentor feedback that build fluency fast

Keep handy

  • Searchable offline docs, handy for C# and .NET API lookups while you practise

Also worth your time

Mark this stage as not done?