Export (0) Print
Expand All

Exception Handling Fundamentals

The common language runtime supports an exception handling model based on the concepts of exception objects and protected blocks of code. The runtime creates an object to represent an exception when it occurs. You can also create your own exception classes by deriving classes from the appropriate base exception.

All languages that use the runtime handle exceptions in a similar manner. Each language uses a form of try/catch/finally structured exception handling. This section provides several examples of basic exception handling.

In This Section

Using the Try/Catch Block to Catch Exceptions
Describes how to use the try/catch block to handle exceptions.
Using Specific Exceptions in a Catch Block
Describes how to catch specific exceptions.
Throwing Exceptions
Describes how to throw exceptions and how to catch exceptions and then throw them again.
Using User-Defined Exceptions
Describes how to create your own exception classes.
Using User-Filtered Exceptions
Describes how to set up filtered exceptions.
Using the Finally Block
Explains how to use the finally statement in an exception block.

Related Sections

Exceptions Overview
Provides an overview of common language runtime exceptions.
Exception Class
Describes the elements of an exception object.
Show:
© 2014 Microsoft