13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 12 Variables• The definite assignment state of v at the beginning of try-block is the same as the definiteassignment state of v at the beginning of stmt.• The definite assignment state of v at the beginning of finally-block is the same as the definiteassignment state of v at the beginning of stmt.• The definite assignment state of v at the end-point of stmt is definitely assigned if (and only if)either:o v is definitely assigned at the end-point of try-blocko v is definitely assigned at the end-point of finally-blockIf a control flow transfer (such as a goto statement) is made that begins within try-block, and ends outsideof try-block, then v is also considered definitely assigned on that control flow transfer if v is definitelyassigned at the end-point of finally-block. (This is not an only if—if v is definitely assigned for anotherreason on this control flow transfer, then it is still considered definitely assigned.)12.3.3.15 Try-catch-finally statementsDefinite assignment analysis for a try-catch-finally statement of the form:try try-blockcatch(…) catch-block-1…catch(…) catch-block-nfinally finally-blockis done as if the statement were a try-finally statement enclosing a try-catch statement:try {try try-blockcatch(…) catch-block-1…catch(…) catch-block-n}finally finally-block[Example: The following example demonstrates how the different blocks of a try statement (§15.10) affectdefinite assignment.class A{static void F() {int i, j;try {goto LABEL;// neither i nor j definitely assignedi = 1;// i definitely assigned}catch {// neither i nor j definitely assignedi = 3;// i definitely assigned}107

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!