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

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.

主站蜘蛛池模板: 九江市| 喀喇| 资溪县| 贞丰县| 江门市| 武陟县| 三江| 湘潭市| 岳普湖县| 永寿县| 芦溪县| 白朗县| 永春县| 桓台县| 札达县| 普安县| 凉山| 福安市| 宁海县| 仙居县| 荆门市| 江孜县| 祁连县| 彰武县| 嘉义县| 阳泉市| 油尖旺区| 库尔勒市| 齐河县| 东阳市| 青阳县| 博野县| 外汇| 民丰县| 边坝县| 合水县| 合川市| 万载县| 巴楚县| 蚌埠市| 台北市|