LANGUAGE

Nullable reference annotation

In a nullable-enabled context, marks a string reference as potentially null. It affects static null-state warnings, not runtime string type identity. An empty string is distinct from null.

Formal Syntax & Structure

csharp syntaxcsharp
string? <identifier> = null;

Working Example

Example Snippetcsharp
string? note = null;System.Console.WriteLine(note == null);
C# & .NET Reference