# If-Else Statement

A statement that executes one of two code blocks depending on a condition.

## What is an **if-else** statement?

A statement that executes one of two code blocks depending on a condition.

```csharp
if(age < 21) {
    price = 14.99;
} else {
    price = 19.99
}

// statements with a single line of code
// can be written like this
if(age < 21) price = 14.99;
else price = 19.99;
```

Level: Novice · [More C# terms at this level](https://www.ask-codey.com/glossary/subjects/c-sharp/novice)

Updated: October 15, 2026

Source: https://www.ask-codey.com/glossary/if-else-statement-c-style
