Nullable reference types C# 8 and later
Context: Nullable reference types help prevent null reference exceptions by distinguishing between nullable and non‑nullable reference types.
#nullable enablestring nonNullable = "Hello";string? nullable = null;nonNullable = nullable; // warning: possible null assignmentReal-world usage example
Section titled “Real-world usage example”API contracts: Mark optional fields as string? and required fields as string. This documents the contract and the compiler enforces null checks.
Example: In ASP.NET Core, model binding respects nullable annotations. The Swagger/OpenAPI generator uses them to mark optional parameters.