Foreach Loop In C# is used to access or iterate each item in a collection. We use foreach, on a string array, to loop through the elements in the array.
class exampleforeach{static void Main(){string[] animals = { "monkey", "elephant", "lion" };// ... Loop with the foreach keyword.foreach (string value in animals ){Console.WriteLine(value);}}}
Output:monkeyelephantlion