Andras Daniel Toth ← Visual Studio My feedback Allow the C# 'break' statement to terminate *several* nested enslosing loops, rather than the closest one only 38 votes Vote Vote Vote Vote Sign in prestine Your name Your email address Check! invalid email (thinking…) Reset or sign in with UserVoice password Forgot password? Create a password I agree to the terms of service Signed in as (Sign out) Close Close 1 vote 2 votes 3 votes Remove votes You have left! (?) (thinking…) 12 comments · Visual Studio IDE » Languages - C# · Flag idea as inappropriate…Flag idea as inappropriate… · Delete… · Admin → Andras Daniel Toth commented · Sep 1, 2014 · Delete… Why don't you refactor these loops into a method? Then you can use 'return'. public Stuff DoingMyNestedLoop() { for { for { if (true) return stuff; } } } usage: for (;;) { DoingMyNestedLoop(); } It will exit all inner loops except for your only outer loop. :)
Why don't you refactor these loops into a method? Then you can use 'return'.
public Stuff DoingMyNestedLoop()
{
for
{
for
{
if (true) return stuff;
}
}
}
usage:
for (;;)
{
DoingMyNestedLoop();
}
It will exit all inner loops except for your only outer loop. :)