Looping Statements (C# vs Java)
Looping statements repeat a specified block of code until a given condition is met.
The syntax and operation of for loops is the same in both C# and Java:
C# introduces a new loop type called the foreach loop, which is similar to Visual Basic's For Each. The foreach loop enables iterating through each item in a container class, such as an array, that supports the IEnumerable interface. The following code illustrates the use of the foreach statement to output the contents of an array:
For more information, see Arrays (C# vs Java).