Exception Handling

Exception handling is implemented in the CLR. Each managed language exposes exception handling in a language-specific manner. In C#, there are the try, catch, throw, and finally keywords. The language compiler, such as csc, compiles code for exception handling into language-agnostic MSIL code. For the details of exception handling in C#, read Chapter 12.

There are two strategies for implementing exception handling in MSIL code: as an exception clause or as scoped exceptions.

Exception clauses are found after the core MSIL code of a method in the exception-handling section. An exception clause identifies the protected block, the exception filter, and the exception handler. Execution must fall into a protected block naturally. To ...

Get Programming Microsoft® Visual C#® 2008: The Language 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.