tutorial

Page 177

When the exception is thrown, execution flow is transferred to the catch block that is capable of handling the exception thus skipping the rest of the code below the line that threw the exception in the try block. The code in the catch block handles the exception appropriately and then execution flow moves to the code in the finally block.

7.4 System.Exception: The mother of all exceptions Let’s take some time to look at the parent exception class in the .NET framework – the System.Exception class. All exception classes are directly or indirectly derived from this class.

To see how to put this class to use, let’s quickly dive into a simple example where we can see all the exception handling constructs (try, catch, throw, and finally) in action. To start with fire up your favorite text editor (my personal favorite is Notepad) and type in the following code:


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.