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

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

主站蜘蛛池模板: 甘德县| 冷水江市| 巴南区| 青州市| 新建县| 伊川县| 怀集县| 莱芜市| 新余市| 湘乡市| 连平县| 汝城县| 锦屏县| 东方市| 内乡县| 阳高县| 乌兰浩特市| 临沂市| 山东| 洪江市| 乌拉特前旗| 武清区| 光泽县| 潞城市| 清丰县| 瑞丽市| 阿巴嘎旗| 长宁县| 新巴尔虎右旗| 喀什市| 东辽县| 云龙县| 奉贤区| 陆川县| 尉犁县| 丰台区| 上栗县| 娄烦县| 仪征市| 咸丰县| 井研县|