This lesson teaches you how to use C# Selection Control Statements. More specifically, the looping statements. | Tutorial Page 1 of 6 Using Excellent Tools to Write Web Applications Tar the .NET Common Language Runtime CLR Home Up Lesson01 Lesson02 Lesson03 Lesson04 Les Lesson06 Lesson07 Lesson08 Lesson09 Lesson10 Les Lesson12 Lesson13 On sale Now C Unleashed is an indepth guide for intermediate to advanced software developers to learn the C programming language and serve as a desktop reference. The C Station Tutorial by Joe Mayo 9 7 00 Lesson 4 Control Statements - Loops This lesson teaches you how to use C Selection Control Statements. Mor specifically the looping statements. It s goal is to meet the following objectives Learn the while loop. Learn the do loop. Learn the for loop. Learn the foreach loop. Complete your knowledge of the break statement. Teach you how to use the continue statement. In the last lesson you learned how to create a simple loop by using the goto statement. I advised you that this is not the best way to perform loops in C . The information in this lesson will teach you the proper way to execute iterative logic with the various C looping statements. Our first statement is the while loop. Listing 4-1. The While Loop using System class WhileLoop public static void Main int myInt 0 while myInt 10 0 myInt myInt http Tutorials 6 24 2002 Tutorial Page 2 of 6 Listing 4-1 shows a simple while loop. It begins with the keyword while followed by a boolean expression. All control statements use boolean expressions. This means that the expression must evaluate to either a true or false value. In this case we are checking the myInt variable to set if it is less than 10. Since myInt was initialized to 0 the boolean expression will return true the first time it is evaluated. When the boolean expression evaluates to true the block immediately following th boolean expression will be executed. Within the while block we print the number and a space to the console. Then we increment myInt .