> ## Documentation Index
> Fetch the complete documentation index at: https://ancplua.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AL0016 - Combine declaration with subsequent null-check

> Combines a variable declaration and an immediate null-check into a single pattern match

## Description

Combines a variable declaration and an immediate null-check into a single pattern match.

## Bad Code

```csharp theme={null}
var x = GetValue();
if (x != null)
{
    Use(x);
}
```

## Good Code

```csharp theme={null}
if (GetValue() is { } x)
{
    Use(x);
}
```

## Properties

* **Category**: Style
* **Severity**: Info
* **Enabled by default**: True
* **Code fix available**: True

## Configuration

```editorconfig theme={null}
dotnet_diagnostic.AL0016.severity = warning
```
