Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0080 while loop

while loop statement uses a bool value to control a loop body. The while loop has the following form. while(bool expression){ loop body } using System; class Program { static void Main(string[] args) { int i = 5; while (i > 0) { Console.WriteLine(i); i--; } } } The output: 5 4 3 2 1