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

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.

主站蜘蛛池模板: 哈尔滨市| 基隆市| 维西| 尉氏县| 新和县| 黄梅县| 醴陵市| 嘉黎县| 榆树市| 天台县| 浪卡子县| 祥云县| 于都县| 隆尧县| 浑源县| 明溪县| 安义县| 松阳县| 雅安市| 治多县| 衡山县| 富民县| 潮州市| 成安县| 思南县| 江西省| 吉木乃县| 朔州市| 厦门市| 红河县| 珲春市| 凌源市| 昌邑市| 胶南市| 商城县| 沾益县| 乌鲁木齐县| 台中县| 鸡东县| 灵山县| 新郑市|