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

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

break

This terminates the control flow for loop or in switch statement. Take a look at the following example:

private static void BreakStatementExample() 
{ 
WriteLine("break statement example"); 
WriteLine("break in for loop"); 
for (int count = 0; count < 50; count++ 
{ 
if (count == 8) 
   { 
    break; 
   } 
WriteLine($"{count}"); 
} 
WriteLine(); 
WriteLine("break in switch statement"); 
SwitchCaseExample(); 
} 

In the preceding code, execution of the for loop will break as soon as the if expression evaluates to true.

主站蜘蛛池模板: 洪洞县| 永德县| 保德县| 灵璧县| 海盐县| 吴江市| 孝义市| 秦安县| 华阴市| 汉阴县| 巴南区| 南溪县| 屏边| 马公市| 织金县| 高淳县| 元阳县| 安仁县| 邛崃市| 疏附县| 布尔津县| 三台县| 德钦县| 定边县| 资阳市| 盈江县| 勐海县| 贵州省| 汉阴县| 西城区| 阳泉市| 明光市| 社旗县| 江孜县| 谢通门县| 徐州市| 客服| 鹤壁市| 阜康市| 肇源县| 富源县|