Break inner foreach loop and continue outer foreach loop
问题 If I have a nested foreach loop how do I do break the inner loop and tell the outer to continue at that point without doing any other code below the inner loop? 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(); } 回答1: How about using a flag? foreach(var item in items) { bool flag = false; foreach(var otheritem in otheritems) { if (!double.TryParse(otheritem