Louis Waweru
Louis Waweru

Reputation: 3672

VB.Net's For Next

Is there a difference between these?

For i = 0 To Something.Length - 1
  'do something
Next

For i = 0 To Something.Length - 1
  'do something
Next i

Upvotes: 5

Views: 230

Answers (2)

Bala R
Bala R

Reputation: 109037

Nope. There is no difference. Even with nested loops there is no difference because nested for-loops cannot overlap.

Upvotes: 1

ThiefMaster
ThiefMaster

Reputation: 318758

It is only for readability:

You can optionally specify counter in the Next statement. This improves the readability of your program, especially if you have nested For loops. You must specify the same variable as the one that appears in the corresponding For statement.

From http://msdn.microsoft.com/en-us/library/5z06z1kb.aspx

Upvotes: 8

Related Questions