# If-Else Statement

*noun*

say it: **“IF ELS STAYT-ment”** **/ɪf ɛls ˈsteɪtmənt/**

A statement that runs one block of code when a condition is true and another when it is false.

## 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;
```

## In a sentence

- “The **if-else statement** prints "Win" or "Loss" depending on the score.”

Level: Novice · [More C# terms at this level](https://www.ask-codey.com/glossary?category=c-sharp&level=1)

Updated: November 9, 2026

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