In C#, suppose there are two nested loops (each loop can be either while or for loop). In the middle of the inner loop, I would like to break out of both loops when a condition is true,
loop1
{
...
loop2
{
...
(I want to break out of both loops, when some condition is true)
...
}
...
}
Is there a more elegant way than
loop1
{
...
loop2
{
...
if (condition)
break
...
}
if (condition)
break
...
}
Thanks.