Looping in C#

Looping in C#: While Loop, Do-While Loop, For Loop, Foreach Loop.

Updated

  1. While Loop (Novice): Repeat a block of code for as long as a condition stays true with C#'s while loop, and make sure the loop can end.
  2. Do-While Loop (Apprentice): Run a block of code at least once, then repeat it while a condition is true, with C#'s do-while loop.
  3. For Loop (Novice): Count through a range of numbers, or through an array's indexes forward, backward or in steps, with C#'s for loop.
  4. Foreach Loop (Apprentice): Visit every element of an array without an index using C#'s foreach loop, and leave a loop early with break or skip ahead with continue.