Zebra0.com

csharp loops


This loop executes 0 times because num>0 is false to start:

int num = 0;
while (num >0)
{
    num++;
    lstNumbers.Items.Add(num);
}

This loop is an endless (or infinite) loop because num>0 is true to start, and keeps getting bigger, num>0 will always be true:

 int num = 1;
 while (num >0)
 {
   num++;
   lstNumbers.Items.Add(num);
}

End of lesson, Next lesson: