0
Enhanced for loop
I can't understand about enhanced for loop About its idea
2 Antworten
+ 2
If you are working with arrays and collections, you can use alternative syntax of for loop (enhanced form of for loop) to iterate through items of arrays/collections. It is also referred as for-each loop because the loop iterates through each element of array/collection.
+ 1
In which language?
Basically it iterates inside a collection (array, list etc) and usually performs tasks on it.
Basic foreach in c#
int[] arrayX = {1,4,5,12};
foreach (int x in arrayX) {
Console.WriteLine(x);
}
Each value inside the arrayX collection will get
1) stored inside x
2) printed using writeline