Zebra0.com

csharp loopsLoops in C#

Loops in C#


Text of video

Code to add 1, 2, 3 to lstNumbers without loop:

 //Add numbers 1, 2, 3 to list box, NO loop
int num = 0;
num++;
lstNumbers.Items.Add(num);
num++;
lstNumbers.Items.Add(num); 
num++;
lstNumbers.Items.Add(num);

Code to add 1, 2, 3 to lstNumbers with while loop:

//Add numbers 1, 2, 3 to list box, with WHILE loop
int num = 0;
while (num < 3)
{
  num++;
  lstNumbers.Items.Add(num);
}

That's all! Congratulations on completing all of the lessons in csharp!