> ## 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.

# AL0047 - Use zero-guard helper

> Use Guard.NotZero() instead of verbose if (x == 0) throw patterns

Source: [Al0047UseGuardNotZeroAnalyzer.cs](https://github.com/ANcpLua/ANcpLua.Analyzers/blob/main/src/ANcpLua.Analyzers/Analyzers/Al0047UseGuardNotZeroAnalyzer.cs)

## Description

Use `Guard.NotZero()` instead of verbose zero-check and throw patterns.

## Bad Code

```csharp theme={null}
public void Divide(int divisor)
{
    if (divisor == 0)
        throw new ArgumentException("Cannot be zero", nameof(divisor));
}
```

## Good Code

```csharp theme={null}
public void Divide(int divisor)
{
    Guard.NotZero(divisor);
}
```

## Properties

* **Category**: Roslyn Utilities
* **Severity**: Warning
* **Enabled by default**: True
* **Code fix available**: True

## Configuration

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