English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

In java, if we don't want to catch the exception inside a method, we can throw the exception so that it would be handled outside the method like this:

public void doSomething() throws Exception{...}

I would like to know if I can write something like this in .NET:

Public Sub DoSomething() Throws Exception
...
End Sub

I just need a simple answer. Thank you very much.

2007-04-28 14:42:10 · 2 answers · asked by Hello World 1 in Computers & Internet Programming & Design

2 answers

You do not need to direct exception handling in VB.net it is automatically done. Any thrown exception ocurring in a sub/function which is not handled in the called sub/function will be carried back to the calling sub/function. The exception will be then handled by the first available error handler. If no error handler is available then an unhandled exception will be thrown and handled at the program level terminating the program.

2007-04-28 15:57:37 · answer #1 · answered by MarkG 7 · 0 0

No. VB.NET doesn't care if or when you throw the exception. It just happens.

2007-04-28 21:50:15 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers