C# foreach 循环项软“中断”
假设我有一个 foreach 循环来对 List MyTypeInstanveVariable 执行一些处理,
foreach(MyType item in MyTypeInstanceVariable) {
if (cond1) {}
if (cond2) {}
}
如果满足 cond1,我想前进到 MyTypeInstanceVariable 中的下一项。现在我可以添加一点布尔值来检查是否评估 cond2,但是是否有一些内置命令可以快速移动到下一个项目?我不能使用break,因为这会完全脱离foreach循环
谢谢 托马斯
let's say I have a foreach loop to perform some processing on 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. 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? I can't use break as that would break out of the foreach loop altogether
Thanks
Thomas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找
continue
语句。You are looking for the
continue
statement.也许继续?
http://msdn.microsoft.com/en-我们/library/923ahwt1(v=vs.71).aspx
perhaps continue?
http://msdn.microsoft.com/en-us/library/923ahwt1(v=vs.71).aspx