Structured Exception Handling

At the advent of an exception, the CLR evaluates the stack to determine where an exception is trapped, if at all, and how it is handled. When an exception occurs, the stack is walked in search of an appropriate exception handler. When a catch filter that matches the exception is located, the exception is handled in the related exception handler, which is the catch statement block. This sets the scope of the exception on the stack. Before the exception is handled, the CLR unwinds the stack to that scope.

Try Statements

Try blocks are observers; they watch for exceptions in the code they protect. Place only code that is prone to an exception in a try block. Do not attempt to protect an entire application in a try block—there ...

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.