Code inspection: Replace control-flow flag with labeled 'break' or 'continue'
This inspection reports a Boolean flag that is used only to control loop execution, for example, to exit an outer loop from an inner loop. Starting with C# 15, you can use a labeled break or continue statement instead of the flag.
Example
var found = false;
foreach (var row in rows)
{
foreach (var value in row)
{
if (value == target)
{
found = true;
break;
}
}
if (found)
break;
}
outer:
foreach (var row in rows)
{
foreach (var value in row)
{
if (value == target)
break outer;
}
}
27 October 2026