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

# if-Statements

Mit `if`-Statements können wir einen Codeblock ausführen, wenn eine bestimmte Bedingung `true` ist.

```csharp theme={null}
if (condition)
{
    ..
}
```

Diese `condition` muss immer einen Boolean zurückgeben, wir können hier also mit [Vergleichsoperatoren](http://w3schools.com/cs/cs_operators_comparison.php) und [logischen Operatoren](/dotnet/c/variablen/booleans#logische-operatoren) arbeiten.

### `else`

Mit dem `else`-Keyword können wir noch einen weiteren Codeblock an das `if`-Statement anhängen, falls die `condition` `false` ist.

```csharp theme={null}
if (condition)
{
    ..
}
else 
{
    ..
}
```

### `else if`

Mit `else if` können wir nach einer weiteren Condition überprüfen.

```csharp theme={null}
if (condition1)
{
    ..
}
else if (condition2)
{
    ..
}
else
{
    ..
}
```

<Info>
  Wir können natürlich beliebig viele `else if` anhängen.
</Info>
