# if Statement

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

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

## What does **if Statement** do in C#?

**if Statement** — A statement that runs code only when its condition is true.

```csharp
class Venue
{
    bool CanEnter(int age)
    {
        bool isAdult = age >= 18;
        bool isSenior = age >= 65;
        return isAdult && !isSenior;
    }
}
```

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

Updated: November 17, 2026

## In other subjects

- [If Statement in C#](https://www.ask-codey.com/glossary/if-statement-c-style)
- [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-sharp
