while statement
The C# loop that repeats its body for as long as its condition stays true.
In more detail
Something in the body must eventually make the condition false, or the loop never ends. It checks the condition before each pass, so the body may run zero times.
Related terms
- for statement — The C# loop that repeats while a condition holds, with an initialiser and an update step, used when the index matters.
- foreach — The C# loop that asks a collection for its enumerator and hands you one item at a time.
Taught in
- The C# Language: Types, Variables, and Flow Control — Modern .NET Core, C# & Enterprise Microservices