A null reference does not refer to an object. In C#, reference types such as string can be null; nullable reference annotations make that possibility explicit so the compiler can check for potential problems. section 2.8
Listing 2.15 Options Text property without the shorthand
public record Options
{
private string? _text; #1
[Value(0, Required = true)]
public string? Text
{
get
{
return _text; #2
}
init #3
{
_text = value; #4
}
}
}
The Options.Text property and its backing field are both marked nullable with string?. section 2.8
A required command-line parameter may still prompt a compiler warning: the parser knows it will not create Options without the parameter, but the compiler does not. Nullable reference types support compile-time checks, while backward compatibility means C# still has multiple null-related operators and nullable types. section 2.8


































