Nullable Types in C#

Nullable Types in C#: Nullable Value Types, The Null-Coalescing Operators ?? and ??=, The Null-Conditional Operator ?., Nullable Reference Types.

Updated

  1. Nullable Value Types (Apprentice): Store "no value yet" in an int?, decimal? or bool?, check it with HasValue or null before you read it, and write an optional parameter that a call can leave out.
  2. The Null-Coalescing Operators ?? and ??= (Apprentice): Give a stand-in for a null value with ??, try several values in turn with a ?? b ?? c, and fill in a variable only when it's null with ??=.
  3. The Null-Conditional Operator ?. (Apprentice): Read a property, call a method or get an array item from something that may be null with ?. and ?[], which give null instead of stopping the program, and add ?? for a stand-in.
  4. Nullable Reference Types (Apprentice): Mark the strings, arrays and objects that may be null as string? or Player?, read the compiler's null warnings as crashes it sees coming, and answer each with a null check, a default, ?. or ??, keeping ! for the rare last resort.