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')) { continue orig; } } // other code comes here... }
Edit: OK it seems there is no such equivalent (hey – Jon Skeet himself said there isn’t, that settles it ;)). So the ‘solution’ for me (in its Java equivalent) is:
for(String a : foo) { bool foundBuzz = false; for (String b : bar) { if (b.equals('buzz')) { foundBuzz = true; break; } } if (foundBuzz) { continue; } // other code comes here... }
I don’t believe there’s an equivalent, I’m afraid. You’ll have to either use a boolean, or just ‘goto’ the end of the inside of the outer loop. It’s even messier than it sounds, as a label has to be applied to a statement – but we don’t want to do anything here. However, I think this does what you want it to:
I would strongly recommend a different way of expressing this, however. I can’t think that there are many times where there isn’t a more readable way of coding it.