Process of Exception Handling

The try block can enclose the lines of code that are expected to generate an error or throw an exception. The throw statement is used to explicitly throw an exception. When an error or exception occurs, the system searches the program for a catch block that can handle the exception. The course of action that the program control takes from the moment the exception is thrown to the moment an appropriate exception handler or catch block is found is called exception propagation. Exception propagation involves repetition as many times as required to find a catch block that can handle the exception thrown.

If the try block that throws an exception has one or more catch blocks associated with it in the same function member, ...

Get Special Edition Using C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.