9.2. The while Loop
The while statement executes a statement or a block of statements until a specified expression evaluates to false. It takes this form:
while (expression) statement
where
expression is an expression that can be implicitly converted to bool or a type that contains overloading of the true and false operators. The expression is used to test the loop-termination criteria.
statement is the embedded statement(s) to be executed.
Because the test of expression takes place before each execution of the loop, a while loop executes zero or more times. A while loop can be terminated when a break, goto, return, or throw statement transfers control outside the loop. To pass control to the next iteration without exiting the loop, you use the ...
Get .NET for Java Developers: Migrating to C# now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.