Nullable reference types — compiler annotation to track nullability.
Enable in .csproj:
1<Nullable>enable</Nullable>
Syntax:
1string name = "Alice"; // Non-nullable2string? nickname = null; // Nullable34void Process(string input) { } // Expects non-null5void Process(string? input) { } // Accepts null
Operators:
1string name = GetNull(); // Warning!2string name = GetNull()!; // No warning3string name = GetNull() ?? "default"; // Handle null4string? name = GetNull(); // Explicit nullable
Benefits:
Note: Reference types always nullable at runtime — annotations are compiler-only.