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

Code Example 1

int[,] numbers2D = new int[3, 2] { { 9, 99 }, { 3, 33 }, { 5, 55 } };
// Or use the short form:
// int[,] numbers2D = { { 9, 99 }, { 3, 33 }, { 5, 55 } };

foreach (int i in numbers2D)
{
    System.Console.Write("{0} ", i);
}
// Output: 9 99 3 33 5 55

Code Example 2

someList.ForEach(x => { if(x.RemoveMe) someList.Remove(x); });

Code Example 3

static void Main()
{
    // Add first 4 numbers to the List.
    List<int> primes = new List<int>();
    primes.Add(2);
    primes.Add(3);
    primes.Add(5);
    primes.Add(7);
}

Code Example 4

List<object> list = enumerable.ToList();

Code Example 5

List<string> someList = <some way to init>
someList.ForEach(delegate(string s) {
    <process the string>
});

Learn ReactJs, React Native from akashmittal.com