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

Continue

This is used to invoke the next iteration. The contextual keyword allows the developer to continue to the next step without executing any further code in the block.

Now, let's look at how we can use both of these contextual statements in our program:

var x = 0;
while(x<=10)
{
x++;
if(x == 2)continue;
Console.WriteLine(x);
if(x == 5) break;
Console.WriteLine("End of loop body");
}
Console.WriteLine($"End of loop, X : {x}");

The preceding code will skip execution of the body for the iteration value, 2, because of the continue statement. The loop will execute until the value of x is 5 because of the break statement.

主站蜘蛛池模板: 正宁县| 酒泉市| 宜兰市| 楚雄市| 宽城| 宁海县| 壶关县| 临沂市| 邓州市| 乌鲁木齐县| 广元市| 新民市| 林芝县| 深州市| 扶风县| 德庆县| 吉水县| 东乡| 怀集县| 武城县| 会宁县| 什邡市| 潞城市| 札达县| 于田县| 闻喜县| 伊金霍洛旗| 元阳县| 藁城市| 石楼县| 丹棱县| 屯门区| 合山市| 河间市| 拉孜县| 吐鲁番市| 隆尧县| 灵山县| 任丘市| 亳州市| 西乌珠穆沁旗|