O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The while Loop Statement

The while loop repeats a statement or compound statement again and again, here referred to as loop body, as long as its associate loop condition, consisting of a Boolean expression, is true (see Syntax Box 9.1). When the loop condition is false while being evaluated, flow of control moves to the line immediately following the while loop.

Syntax Box 9.1 The while-Loop

						while_statement:=
while (<Loop_condition>)
    <Loop_body>

where:

<Loop_condition>::= <Boolean_expression>

<Loop_body>::= <Statement>;
           ::= <Compound_statement>

Note:

  • The loop body is repeated as long as <Loop_condition> is true.

The keyword while is suitably chosen; we can even use it to describe the semantics of the while loop in plain English:

While (the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required