Using do...while to Loop an Indeterminate Number of Times
In some situations, you won't know the exact number of times a loop needs to be performed—not even when the loop begins. When you need to create such a loop, using the do...while loop is the best solution.
The do...while comes in a number of flavors. Its most basic form has the following syntax:
do statement while (expression);
The following syntax is used to execute multiple statements: do { [Statements] } while (expression); |
Ending a do...while Loop
A do...while loop without some sort of exit mechanism or defined condition is an endless loop. In its most basic form, nothing is present ...
Get Sams Teach Yourself Microsoft® Visual C#™ .NET in 24 Hours 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.