Tsallaka zuwa abun ciki
Justice Tech School

Nullable Reference Types

With nullable enabled the compiler warns about null. ? marks may be null and ! says trust me.

Example
string a = "text";
string? b = null;
Console.WriteLine(a.Length);
Console.WriteLine(b?.Length);
Console.WriteLine(b!.Length);

Exercise

May be null.

string s

Quiz Test

What does ! do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.