Mega Code Archive

 
Categories / C# Tutorial / Statement
 

Use a while loop to display 1 to 5

class MainClass {   public static void Main()   {     int counter = 1;     while (counter <= 5)     {       System.Console.WriteLine("counter = " + counter);       counter++;     }   } } counter = 1 counter = 2 counter = 3 counter = 4 counter = 5