X hits on this document

860 views

0 shares

0 downloads

0 comments

197 / 396

C# LANGUAGE SPECIFICATION

If an exception is propagated to the try statement during execution of the try block:

The catch clauses, if any, are examined in order of appearance to locate a suitable handler for the exception. The first catch clause that specifies the exception type or a base type of the exception type is considered a match. A general catch clause is considered a match for any exception type. If a matching catch clause is located:

If the matching catch clause declares an exception variable, the exception object is assigned to the exception variable.

Control is transferred to the matching catch block.

When and if control reaches the end point of the catch block:

If the try statement has a finally block, the finally block is executed.

Control is transferred to the end point of the try statement.

If an exception is propagated to the try statement during execution of the catch block:

If the try statement has a finally block, the finally block is executed.

The exception is propagated to the next enclosing try statement.

If the try statement has no catch clauses or if no catch clause matches the exception:

If the try statement has a finally block, the finally block is executed.

The exception is propagated to the next enclosing try statement.

The statements of a finally block are always executed when control leaves a try statement. This is true whether the control transfer occurs as a result of normal execution, as a result of executing a break, continue, goto, or return statement, or as a result of propagating an exception out of the try statement.

If an exception is thrown during execution of a finally block, the exception is propagated to the next enclosing try statement. If another exception was in the process of being propagated, that exception is lost. The process of propagating an exception is discussed further in the description of the throw statement (§‎8.9.5).

The try block of a try statement is reachable if the try statement is reachable.

A catch block of a try statement is reachable if the try statement is reachable.

The finally block of a try statement is reachable if the try statement is reachable.

The end point of a try statement is reachable if both of the following are true:

The end point of the try block is reachable or the end point of at least one catch block is reachable.

If a finally block is present, the end point of the finally block is reachable.

8.11 The checked and unchecked statements

The checked and unchecked statements are used to control the overflow checking context for integral-type arithmetic operations and conversions.

checked-statement: checked   block

unchecked-statement: unchecked   block

The checked statement causes all expressions in the block to be evaluated in a checked context, and the unchecked statement causes all expressions in the block to be evaluated in an unchecked context.

184Copyright Microsoft Corporation 1999-2003. All Rights Reserved.

Document info
Document views860
Page views860
Page last viewedMon Dec 05 10:12:39 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments