what is a for each loop c# code example
Example 1: The foreach Loop c#
string[] names = {"William.", "James", "Oliver", "Lucas"};
foreach (string i in names)
{
Console.WriteLine(i);
}
Example 2: syntax foreach loop C#
foreach (type variableName in arrayName)
{
// code block to be executed
}