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

  • 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.

主站蜘蛛池模板: 法库县| 马边| 龙南县| 会宁县| 南丹县| 宝兴县| 荣昌县| 吉安县| 大名县| 綦江县| 沁源县| 万盛区| 苏州市| 平顺县| 汕头市| 东光县| 双桥区| 丹东市| 南充市| 南和县| 望城县| 奎屯市| 霍林郭勒市| 玉田县| 邓州市| 鲜城| 江西省| 平武县| 望城县| 滨海县| 分宜县| 上饶县| 林芝县| 拉萨市| 马公市| 杭锦旗| 富裕县| 南丰县| 五河县| 镶黄旗| 沿河|