Nullable Reference Type

noun

say it: “NUL-uh-bul REF-er-ens type” /ˈnʌləbəl ˈrɛfərəns taɪp/

A reference type written with a ?, like string?, to say that its value may be null.

What is Nullable Reference Type in C#?

Nullable Reference Type — A reference type written with a ?, like string?, to say "this may be null". The compiler then warns you wherever you use it without checking, and treats plain string as never null.

string? region = null;          // fine: may be null
Console.WriteLine(region ?? "(no region)"); // (no region)

In a sentence

  • “Region is a nullable reference type, string?, because some customers have no region.”

Level: Journeyman · More C# terms at this level

Updated