C#:Iterating (loops)

From Progzoo
Jump to: navigation, search
C#:Iterating (loops)
for
foreach
while

You can "iterate" to loop over a set of values.

for
The for loop is often used to loop over numbers - 0,1,2,3,4,5,6,7,8,9 for example
foreach
You use foreach loops to run over the values in an array or a list
while
You can use a while loop to keep looping until some condition is achieved