Jon Jagger
jon@jaggersoft.com
Table of Contents 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Notes DownloadECMA-334 C# Language Specificationpreviousnextprevious at this levelnext at this level 12 Variablesprevious at this levelnext at this level 12.1 Variable categoriesprevious at this levelnext at this level 12.1.7 Local variables Paragraph 11 A local variable is declared by a local-variable-declaration, which may occur in a block, a for-statement, a switch-statement, or a using-statement. Paragraph 21 The lifetime of a local variable is the portion of program execution during which storage is guaranteed to be reserved for it. 2 This lifetime extends from entry into the block, for-statement, switch-statement, or using-statement with which it is associated, until execution of that block, for-statement, switch-statement, or using-statement ends in any way. 3 (Entering an enclosed block or calling a method suspends, but does not end, execution of the current block, for-statement, switch-statement, or using-statement.) 4 If the parent block, for-statement, switch-statement, or using-statement is entered recursively, a new instance of the local variable is created each time, and its local-variable-initializer, if any, is evaluated each time. Paragraph 31 A local variable is not automatically initialized and thus has no default value. 2 For the purpose of definite assignment checking, a local variable is considered initially unassigned. 3 A local-variable-declaration may include a local-variable-initializer, in which case the variable is considered definitely assigned in its entire scope, except within the expression provided in the local-variable-initializer. Paragraph 41 Within the scope of a local variable, it is a compile-time error to refer to that local variable in a textual position that precedes its local-variable-declarator. [Note: The actual lifetime of a local variable is implementation-dependent. For example, a compiler might statically determine that a local variable in a block is only used for a small portion of that block. Using this analysis, the compiler could generate code that results in the variable's storage having a shorter lifetime than its containing block. The storage referred to by a local reference variable is reclaimed independently of the lifetime of that local reference variable (§10.9). end note] Paragraph 51 A local variable is also declared by a foreach-statement and by a specific-catch-clause for a try-statement. 2 For a foreach-statement, the local variable is an iteration variable (§15.8.4). 3 For a specific-catch-clause, the local variable is an exception variable (§15.10). 4 A local variable declared by a foreach-statement or specific-catch-clause is considered definitely assigned in its entire scope.
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS