# If Statement

*noun*

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

A statement that runs a block of code only when its condition is true.

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

A statement that evaluates a condition before executing some code.

```csharp
if(age > 21) {
    // add one or more statements here
    price = 19.99;
}

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

## In a sentence

- “An **if statement** adds free shipping when the total is over $50.”

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

Updated: November 9, 2026

## In other subjects

- [if Statement in C#](https://www.ask-codey.com/glossary/if-statement-c-sharp)
- [if Statement in Java](https://www.ask-codey.com/glossary/if-statement-java)
- [if Statement in JavaScript](https://www.ask-codey.com/glossary/if-statement-javascript)
- [if Statement in PowerShell](https://www.ask-codey.com/glossary/if-statement-powershell)
- [if Statement in Python](https://www.ask-codey.com/glossary/if-statement)
- [if Statement in Unix](https://www.ask-codey.com/glossary/if-statement-unix)

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