LANGUAGE

notnull constraint

Expresses a non-nullable type-argument contract; violations generally warn with nullable analysis enabled, not runtime checks.

Formal Syntax & Structure

csharp syntaxcsharp
where T : notnull

Working Example

Example Snippetcsharp
static T Keep<T>(T value) where T : notnull => value;
C# & .NET Reference