Check out example codes for "foreach syntax c#". It will help you in understanding the concepts better.

Code Example 1

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}");

Learn ReactJs, React Native from akashmittal.com