how to break foreach in c# code example
Example 1: get out of foreach statement c#
foreach (string s in sList)
{
if (s.equals("ok"))
{
break; // get out of the loop
}
}
Example 2: c# list foreach
someList.ForEach(x => { if(x.RemoveMe) someList.Remove(x); });