[英]C# foreach loop item soft “break”
let's say I have a foreach loop to perform some processing on List MyTypeInstanveVariable 假设我有一个foreach循环来对List MyTypeInstanveVariable执行一些处理
foreach(MyType item in MyTypeInstanceVariable) {
if (cond1) {}
if (cond2) {}
}
If cond1 is met I want to advance to the next item in the MyTypeInstanceVariable. 如果满足cond1,我想前进到MyTypeInstanceVariable中的下一个项目。 Now I could add a little boolean to check whether to evaluate cond2, but is there some built in command that will quickly move onto the next item?
现在我可以添加一个布尔值来检查是否要评估cond2,但是是否有一些内置命令可以快速移动到下一个项目? I can't use break as that would break out of the foreach loop altogether
我不能使用break,因为它会彻底打破foreach循环
Thanks Thomas 谢谢托马斯
您正在寻找continue
语句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.