![]() The following are the important points which we need to remember about the Try-Catch statement. If you observe the above result, the inner Try-Catch statement has failed to handle the exception so the catch block in the outer Try-Catch statement has been handled the exception. In nested Try-Catch statements, if there isn’t any inner Catch block with an appropriate exception type, then the exception will flow to the outer Catch block.įollowing is the example of defining nested Try-Catch statements in visual basic. In visual basic, we can define a Try-Catch statement within another Try-Catch statement based on our requirements. A parameterless catch block ( Catch) or catch block with an exception argument ( Catch ex As Exception) must be the last block if we use it with other catch blocks otherwise we will get a compile-time error.While defining multiple catch blocks, the order of catch blocks must be always from most specific to least specific.Defining a parameterless catch block ( Catch) and catch block with an exception argument ( Catch ex As Exception) are not allowed in the same try-catch statement because both will do the same thing.Multiple Catch blocks with the same exception type are not allowed.The following are the few points which we need to consider while defining a multiple Catch blocks.
0 Comments
Leave a Reply. |