O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The for Loop Statement

As we have seen in many previous examples involving iteration, the three key components of a loop are as follows:

  • Loop condition— When evaluated to true, will cause the loop body to be repeated.

  • Loop initialization— During the loop initialization the variable(s) taking part in the loop condition are assigned initial suitable values. This process only takes place once before the loop commences.

  • Loop update— Updates the variables of the loop condition. This is repeatedly done during every loop.

These are exemplified in Figure 9.6, which uses the source code of the while loop shown earlier. Notice that only the loop condition is restrained by the rules of syntax to a specific position, namely inside a pair of parentheses positioned ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required