Last active
August 29, 2015 14:20
Scope of a local variable in loop (Case 2, 3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub LocalVariableCase2() | |
For i = 0 To 2 | |
Dim value As Boolean = False | |
Console.WriteLine(value) | |
value = True | |
Next | |
'False | |
'False | |
'False | |
End Sub | |
Private Sub LocalVariableCase3() | |
For i = 0 To 2 | |
Dim value As Boolean | |
Console.WriteLine(value) 'No error in VB | |
value = True | |
Next | |
'False | |
'True | |
'True | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment