foreach to for loop in c# code example
Example 1: how do i foreach c#
//No counter just the foreach.
//the HelloWorld is the Class objects name nor a public string can be used aswell.
foreach (string element in fibNumbers)
{
Console.WriteLine(element.HelloWorld);
}
Example 2: The foreach Loop c#
string[] names = {"William.", "James", "Oliver", "Lucas"};
foreach (string i in names)
{
Console.WriteLine(i);
}