Description
Combines a variable declaration and an immediate null-check into a single pattern match.Bad Code
Good Code
Properties
- Category: Style
- Severity: Info
- Enabled by default: True
- Code fix available: True
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Combines a variable declaration and an immediate null-check into a single pattern match
var x = GetValue();
if (x != null)
{
Use(x);
}
if (GetValue() is { } x)
{
Use(x);
}
dotnet_diagnostic.AL0016.severity = warning
Was this page helpful?
