luni, 25 august 2014

Foreach in C# example

Foreach iterates through the collection . It can be exited by the goto, return, or throw.
Note: Cannot be used to add or remove items from the collection to avoid unpredictable side effects

Example


int[] intarray = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
foreach (int el in intarray)
{
MessageBox.Show(el.ToString()); 
}

Niciun comentariu:

Trimiteți un comentariu