null-forgiving operator

A postfix exclamation mark, as in code!.Length, that tells the compiler to assume a value is not null and suppress the nullable warning.

It silences a real warning, so a genuine null slips through to crash at run time.

In more detail

It changes only the warning, not run-time behaviour: if the value is null the program still throws. Use it only where you can prove the value is present.

Related terms

Taught in

References