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

  • Learn C# in 7 days
  • Gaurav Aroraa
  • 109字
  • 2021-07-08 09:51:29

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.

主站蜘蛛池模板: 泰兴市| 尤溪县| 高邮市| 衡阳县| 盘山县| 石棉县| 济宁市| 武夷山市| 赞皇县| 隆回县| 静安区| 从江县| 微博| 开化县| 漯河市| 麻城市| 板桥市| 五常市| 榆树市| 上蔡县| 南充市| 延川县| 天水市| 镇沅| 澎湖县| 温宿县| 丹阳市| 望奎县| 七台河市| 闻喜县| 贺兰县| 波密县| 万盛区| 蚌埠市| 盖州市| 鲁甸县| 安远县| 宕昌县| 镇江市| 林周县| 渑池县|