官术网_书友最值得收藏!

The do...while loop

This helps us execute a statement or a statement of block repeatedly until it evaluates the expression to false. In do...while statement, a block of statement executes first and then it checks the condition under while, which means a statement or block of statements that execute at least once.

Take a look at the following code:

private static void DoWhileStatementExample() 
{ 
WriteLine("do...while example"); 
Write("Enter repeatitive length:"); 
int length = Convert.ToInt32(ReadLine()); 
int count = 0; 
do 
    { 
        count++; 
        WriteLine(newstring('*',count));  
    } while (count < length); 
} 

In the preceding code snippet, the statement of the do block executes until the statement of the while block evaluates to false.

主站蜘蛛池模板: 阳江市| 卫辉市| 遵化市| 万安县| 二连浩特市| 鄢陵县| 邛崃市| 迭部县| 西乌| 乐都县| 日喀则市| 马尔康县| 湖北省| 龙江县| 商南县| 榆中县| 西乌珠穆沁旗| 上饶县| 永仁县| 和林格尔县| 班戈县| 桓仁| 永年县| 株洲市| 昌图县| 郯城县| 金阳县| 柏乡县| 太谷县| 潜山县| 高唐县| 蒙阴县| 游戏| 无锡市| 博兴县| 唐河县| 韶关市| 江口县| 湖北省| 靖江市| 阳谷县|