Foreach Loop

Foreach Loop

For each (or foreach) is a computer language idiom for traversing items in a collection. Foreach is usually used in place of a standard for statement. Unlike other for loop constructs, however, foreach loops usually maintain no explicit counter: they essentially say "do this to everything in this set", rather than "do this x times". This avoids potential off-by-one errors and makes code simpler to read. In object-oriented languages an iterator, even if implicit, is often used as the means of traversal.

Read more about Foreach Loop:  Syntax, Language Support

Other articles related to "foreach loop, foreach":

C Sharp Syntax - Control Structures - Iteration Structures - Foreach Loop
... The foreach statement is derived from the for statement and makes use of a certain pattern described in C#'s language specification in order to obtain and use an ... foreach (int i in intList) {.. ...