A While
loop starts by evaluating a condition. If it is true, the body of the loop is executed. After the body of the loop is executed, the While
condition is evaluated again to determine whether to re-execute the body.
Dim iteration As Integer = 1
While iteration <= 10
Console.Writeline(iteration.ToString() & " ")
iteration += 1
End While
This outputs:
1 2 3 4 5 6 7 8 9 10
Warning: A While
loop can lead to an infinite loop. Consider what would happen if the line of code that increments iteration
were removed. In such a case the condition would never be True and the loop would continue indefinitely.