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

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.

主站蜘蛛池模板: 临沂市| 屏东县| 拜城县| 清徐县| 阳高县| 汉阴县| 米林县| 拜泉县| 弥渡县| 铅山县| 额敏县| 县级市| 扶绥县| 静乐县| 邛崃市| 板桥市| 桐庐县| 正阳县| 闽清县| 临澧县| 克拉玛依市| 来凤县| 会理县| 搜索| 安图县| 武夷山市| 大埔县| 南充市| 柞水县| 英德市| 邹平县| 丹巴县| 洛扎县| 盖州市| 高雄县| 南充市| 嵊泗县| 桦川县| 焉耆| 石棉县| 敦煌市|