Possible Duplicate:
Breaking out of a nested loop
I got somthing like (to simplify)
foreach (...)
{
foreach (...)
{
//Some code
if (statement)
{
break;
}
}
}
The thing is that I want my statement to leave for the double-foreach loop !
I’m thinking about a sort of “break flag” as a boolean but is there any way to avoid that ?
You could avoid the nested loop entirely by using Linq and
SelectMany.Instead of:
Your code would become:
If you need some logic to select whether or not you loop over
SubValues, throw that logic in an additionalWhereclause.Instead of
You can write: