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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.