TYPE

NotNullWhenAttribute

System.Diagnostics.CodeAnalysis attribute describing a non-null argument after the specified Boolean return. The method is responsible for honoring the contract.

Formal Syntax & Structure

csharp syntaxcsharp
[NotNullWhen(true)]

Working Example

Example Snippetcsharp
static bool Has([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] string? s) => s is not null;
C# & .NET Reference