相关疑难解决方法(0)

打破内部foreach循环并继续外部foreach循环

如果我有一个嵌套的foreach循环,我怎么做打破内循环并告诉外部继续在那一点没有在内循环下面做任何其他代码?

foreach(var item in items)
{
  foreach(var otheritem in otheritems)
  {
    if (!double.TryParse(otheritem))
    {
      //break inner loop
      //continue outer loop so we never get to DoStuff()
    }
  }

  DoStuff();
}
Run Code Online (Sandbox Code Playgroud)

.net c# .net-4.0 c#-4.0

25
推荐指数
5
解决办法
3万
查看次数

标签 统计

.net ×1

.net-4.0 ×1

c# ×1

c#-4.0 ×1