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

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.

主站蜘蛛池模板: 措勤县| 博爱县| 秦安县| 额济纳旗| 新郑市| 白城市| 金堂县| 和龙市| 中宁县| 鄱阳县| 西乌| 惠东县| 江口县| 乌审旗| 荣成市| 嘉峪关市| 安阳市| 惠来县| 札达县| 香格里拉县| 巴林右旗| 隆昌县| 南岸区| 黄龙县| 同仁县| 礼泉县| 察雅县| 句容市| 大石桥市| 宿迁市| 红桥区| 和政县| 普兰县| 平邑县| 武邑县| 黎平县| 伊宁县| 甘洛县| 天峨县| 沭阳县| 都江堰市|