do...while

A do statement is always used along with a while statement. The do statement executes a code block and evaluates the while expression. If the while statement evaluates to true, the code block is executed again. This continues as long as while evaluates to true. Because the condition expression is evaluated after the code block is executed, do...while always executes the code block at least once.

break;, continue;, return, or throw can be used to come out of this loop any time during execution:

int intvariable = 0;
do
{
Console.WriteLine("Number is :" + intvariable);
intvariable++;

} while (intvariable < 5);

//Output
Number is :0
Number is :1
Number is :2
Number is :3
Number is :4

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.151.44