J
JimM
I'm curious if anyone knows what the most appropriate way of coding the
following situation:
(Version 1)
Dim x As Integer
For i As Integer = 0 To iLimit
For j As Integer = 0 To jLimit
x = SomeFunction(i,j)
DoSomethingHere(x,i)
If x > 3 Then
DoSomeThingElse(x,j)
End If
Next j
Next i
(Version 2)
For i As Integer = 0 To iLimit
For j As Integer = 0 To jLimit
Dim x As Integer = SomeFunction(i,j)
DoSomethingHere(x,i)
If x > 3 Then
DoSomeThingElse(x,j)
End If
Next j
Next i
Despite former BASIC programming practices, I'm preferring to code these
days with tightly scoped variables when I can (for example, x above).
The second is my preferable approach, but I'm curious if by declaring the
variable within the loops I would incur a performance penalty. Any ideas?
--- Jim ---
following situation:
(Version 1)
Dim x As Integer
For i As Integer = 0 To iLimit
For j As Integer = 0 To jLimit
x = SomeFunction(i,j)
DoSomethingHere(x,i)
If x > 3 Then
DoSomeThingElse(x,j)
End If
Next j
Next i
(Version 2)
For i As Integer = 0 To iLimit
For j As Integer = 0 To jLimit
Dim x As Integer = SomeFunction(i,j)
DoSomethingHere(x,i)
If x > 3 Then
DoSomeThingElse(x,j)
End If
Next j
Next i
Despite former BASIC programming practices, I'm preferring to code these
days with tightly scoped variables when I can (for example, x above).
The second is my preferable approach, but I'm curious if by declaring the
variable within the loops I would incur a performance penalty. Any ideas?
--- Jim ---