Infinite Loop Example in

Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 3379
Dim i As Integer = 0
While i < 1
Console.WriteLine("Infinite Loop")
i += 1
i -= 1
End While

The initial value of i is 0; Then 0 is checked with 1 which is smaller and the condition satisfies. The inner statement inside the loop executed i.e. "Infinite Loop" printed. Then the value of i is incremented to 1. But because of i--, the value got decremented to 0. And the process continues for ever.

Comments or Responses

Login to post response