//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);
}
string[] names = {"William.", "James", "Oliver", "Lucas"};
foreach (string i in names)
{
Console.WriteLine(i);
}
foreach (type element in sequence)
{
statement;
//ex: Console.WriteLine(element);
}
var numbers = new NumberList<int> { 0, 1, 2, 3, 4, 5 };
foreach (int num in numbers)
{
DoSomething();
}
var fibNumbers = new List<int> { 0, 1, 1, 2, 3, 5, 8, 13 };
int count = 0;
foreach (int element in fibNumbers)
{
count++;
Console.WriteLine($"Element #{count}: {element}");
}
Console.WriteLine($"Number of elements: {count}");
foreach (int element in fibNumbers)
{
Console.Write($"{element} ");
}
foreach (int num in numbers)
{
}
int[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
foreach (int i in x)
{
print(i + "8");
}