C# equivalent to Java's continue

前端 未结 5 1756
南笙
南笙 2020-12-14 06:13

Should be simple and quick: I want a C# equivalent to the following Java code:

orig: for(String a : foo) {
  for (String b : bar) {
    if (b.equals(\"buzz\"         


        
5条回答
  •  遥遥无期
    2020-12-14 07:10

    You could do something like:

    for(int i=0; i< foo.Length -1 ; i++) {
      for (int j=0; j< bar.Length -1; j++) {
        if (condition) {
          break;
        }
        if(j != bar.Length -1)
            continue;
        /*The rest of the code that will not run if the previous loop doesn't go all the way*/
      }
    }
    

提交回复
热议问题