Friday 16 September 2011

Variable scope in try catch statement

public class Test
   public Shared Sub Main


        Try
            Dim As Integer = CInt("bad value")
        Catch ex As InvalidCastException
            Dim txt As String = "InvalidCastException"
            Console.WriteLine(txt)
        Catch ex As Exception
            Dim txt As String = "Exception"
            Console.WriteLine(txt)
        End Try

   End Sub
End class

No comments:

Post a Comment