Friday, May 19, 2006

Do Not Declare Variables Inside Try Blocks If You Want To Use Them Later

Try
Dim A As Integer = 1
Catch
Dim A As Integer = 2
End Try

A = 1/(A + 1)


Will not Build inside of VS/VB.NET . Instead say

Dim A
Try
A = 1
Catch
A = 2
End Try

A = 1/(A + 1)

0 Comments:

Post a Comment

<< Home