13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>C#</strong> LANGUAGE SPECIFICATION• The definite assignment state of v before expr-second is definitely assigned if the state of v afterexpr-first is either definitely assigned or “definitely assigned after true expression”. Otherwise, it isnot definitely assigned.• The definite assignment state of v after expr is determined by:o If the state of v after expr-first is definitely assigned, then the state of v after expr isdefinitely assigned.o Otherwise, if the state of v after expr-second is definitely assigned, and the state of v afterexpr-first is “definitely assigned after false expression”, then the state of v after expr isdefinitely assigned.o Otherwise, if the state of v after expr-second is definitely assigned or “definitely assignedafter true expression”, then the state of v after expr is “definitely assigned after trueexpression”.o Otherwise, if the state of v after expr-first is “definitely assigned after false expression”, andthe state of v after expr-second is “definitely assigned after false expression”, then the stateof v after expr is “definitely assigned after false expression”.o Otherwise, the state of v after expr is not definitely assigned.[Example: In the exampleclass A{static void F(int x, int y) {int i;if (x >= 0 && (i = y) >= 0) {// i definitely assigned}else {// i not definitely assigned}// i not definitely assigned}}the variable i is considered definitely assigned in one of the embedded statements of an if statement but notin the other. In the if statement in method F, the variable i is definitely assigned in the first embeddedstatement because execution of the expression (i = y) always precedes execution of this embeddedstatement. In contrast, the variable i is not definitely assigned in the second embedded statement, sincex >= 0 might have tested false, resulting in the variable i's being unassigned. end example]12.3.3.24 || expressionsFor an expression expr of the form expr-first || expr-second:• The definite assignment state of v before expr-first is the same as the definite assignment state of vbefore expr.• The definite assignment state of v before expr-second is definitely assigned if the state of v afterexpr-first is either definitely assigned or “definitely assigned after false expression”. Otherwise, it isnot definitely assigned.• The definite assignment statement of v after expr is determined by:o If the state of v after expr-first is definitely assigned, then the state of v after expr isdefinitely assigned.o Otherwise, if the state of v after expr-second is definitely assigned, and the state of v afterexpr-first is “definitely assigned after true expression”, then the state of v after expr isdefinitely assigned.110

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

Saved successfully!

Ooh no, something went wrong!