Introducing the for loop
The while loop to add 1, 2, 3 to the listbox is changed to a for loop.
Introducing the for loop
The while loop to add 1, 2, 3 to the listbox is changed to a for loop.
Text of video
private void Form1_Load(object sender, EventArgs e)
{
//Add numbers 1, 2, 3 to list box using while loop:
lstNumbers.Items.Add("while");
int num = 1;
while (num <4)
{
lstNumbers.Items.Add(num);
num++;
}
lstNumbers.Items.Add("for");
for (int i=1; i<4; i++)
{
lstNumbers.Items.Add(i);
}
}