Stop Looping C#?
If you are inside a loop and want to abort the loop execution and jump to the code after the loop, insert a break;
statement.
If you only want to stop the current loop iteration, and continue with the rest of the loop, add a continue;
statement instead.
You can stop any loop in c# by a break
statement
You can write something like this:
foreach(var o in list)
{
if (o.SomeValue == 1)
{
break;
}
}
you can skip iteration with
continue;
and stop loop with
break;