# while Loop

*noun*

say it: **“WYLE loop”** **/waɪl luːp/**

A loop that keeps repeating its block as long as its condition stays true.

## What is **while Loop** in C#?

**while Loop** — A loop that repeats while its condition remains true.

```csharp
class Counter
{
    int CountToThree()
    {
        int number = 0;

        while (number < 3)
        {
            number++;
        }

        return number;
    }
}
```

## In a sentence

- “A **while loop** keeps asking for a guess until the player gets it right.”

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

Updated: November 9, 2026

## In other subjects

- [while Loop in Java](https://www.ask-codey.com/glossary/while-loop-java)
- [while Loop in JavaScript](https://www.ask-codey.com/glossary/while-loop-javascript)
- [while Loop in PowerShell](https://www.ask-codey.com/glossary/while-loop-powershell)
- [while Loop in Python](https://www.ask-codey.com/glossary/while-loop)
- [while Loop in Unix](https://www.ask-codey.com/glossary/while-loop-unix)

Source: https://www.ask-codey.com/glossary/while-loop-c-sharp
