c# foreach on a [] 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: The foreach Loop c#
string[] names = {"William.", "James", "Oliver", "Lucas"};
foreach (string i in names)
{
Console.WriteLine(i);
}