# If Statement

A statement that evaluates a condition before executing some code.

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

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

Updated: October 15, 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)

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