Code/Tea/Etc...

Duncan Mackenzie has too much time on his hands

Visual Basic .NET 2003 Language Changes

Although I'll be the first to suggest it should have been up earlier, I wrote a short article about the new VB.NET 2003 language features... and it is up on MSDN now.

Published Friday, March 14, 2003 4:22 PM by Duncanma

Comments

 

Glen said:

Duncan, thanks for the article on language changes. I'm curious about the scope of loop control variables. Given this pseudocode:
<PRE class=code>Dim counter As Integer
For i as Integer = 0 To 10
For j as Integer = 0 to 10
Console.WriteLine(i*j)
Next
Next
</PRE>
will it produce an error? I assume not since the inner loop should be able to access the variable since it's still in the scope of the outer loop. And I would assume that after the inner loop is complete, referencing j would give an error. Would I be correct?
March 27, 2003 1:24 PM
 

Duncan Mackenzie said:

Glen...

Yep, you are correct... the inner loop is still within the scope of the outer, so the i variable is valid within the inner loop, but j is not available outside of the inner loop....

hope that is clearer than it seems when I read it...
March 27, 2003 1:31 PM
Anonymous comments are disabled

This Blog

Syndication

News

This blog has moved to my own VB site

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker