Possible Duplicate:
Breaking out of a nested loop
I have this code
foreach (___)
{
foreach (___)
{
foreach (___)
{
if (condition)
{
//break out of all loops
}
}
}
}
But break
only "breaks" the most inner loop (sorry for my english) and I want to leave them all...
I was thinking about :
Is there any more elegant way ? like provided by C# ?
Thanks in advance for any help !
A very elegant solution to this is to move the entire nest of loops to a separate method and return;
when you want to break out of all loops.