Back to course

The Nullable Type and Null Coalescing

C# Zero to Hero: Comprehensive Programming Masterclass

Handling Nulls

By default, value types cannot be null. Use ? to make them nullable.

Nullable Int

csharp int? age = null;

Null Coalescing Operator (??)

Provides a default value if the variable is null. csharp string display = myName ?? "Guest";