C# 强制循环的迭代
在我的“本机”编程语言(RPG)中,我可以编写一个循环,然后离开循环或强制迭代。这有点像一个后进C# 强制循环的迭代,c#,loops,foreach,C#,Loops,Foreach,在我的“本机”编程语言(RPG)中,我可以编写一个循环,然后离开循环或强制迭代。这有点像一个后进 dow (x < 999); read file; if (%eof); leave; // Leave the loop endif; if (field <> fileField); iter; // Iterate to the next record endif; enddo; 道琼斯指数(x
dow (x < 999);
read file;
if (%eof);
leave; // Leave the loop
endif;
if (field <> fileField);
iter; // Iterate to the next record
endif;
enddo;
道琼斯指数(x<999);
读取文件;
如果(%eof);
离开退出循环
endif;
if(字段fileField);
国际热核实验堆迭代到下一条记录
endif;
enddo;
我的问题是,是否有类似的选择是C#。在我的例子中,我正在使用foreach循环。将退出该循环。
continue; // Goto the next iteration
break; // Exit the loop
将跳转到下一个迭代。使用关键字
+1清晰简洁;这正是我喜欢在答案中看到的。这就是为什么我把它标记为答案。再清楚不过了。
for (int i = 1; i <= 10; i++)
{
if (i < 9)
continue;
Console.WriteLine(i);
}
9
10