Prepare code for loop
Statements to add 1,2,3 to list box individually are converted to a while loop.
Prepare code for loop
Statements to add 1,2,3 to list box individually are converted to a while loop.
Text of videoCode 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);
}