c# list foreach code example
Example 1: c# foreach arra
int[,] numbers2D = new int[3, 2] { { 9, 99 }, { 3, 33 }, { 5, 55 } };
foreach (int i in numbers2D)
{
System.Console.Write("{0} ", i);
}
Example 2: c# list append
static void Main()
{
List<int> primes = new List<int>();
primes.Add(2);
primes.Add(3);
primes.Add(5);
primes.Add(7);
}
Example 3: c# ienumerable to list
List<object> list = enumerable.ToList();
Example 4: c# list foreach
someList.ForEach(x => { if(x.RemoveMe) someList.Remove(x); });
Example 5: c# list.foreach
List<string> someList = <some way to init>
someList.ForEach(delegate(string s) {
<process the string>
});