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 15 Statementsprevious at this levelnext at this level 15.5 Declaration statementsprevious at this levelnext at this level 15.5.1 Local variable declarations Paragraph 11 A local-variable-declaration declares one or more local variables. local-variable-declaration : type local-variable-declarators local-variable-declarators : local-variable-declarator local-variable-declarators , local-variable-declarator local-variable-declarator : identifier identifier = local-variable-initializer local-variable-initializer : expression array-initializer Paragraph 21 The type of a local-variable-declaration specifies the type of the variables introduced by the declaration. Paragraph 31 The type is followed by a list of local-variable-declarators, each of which introduces a new variable. 2 A local-variable-declarator consists of an identifier that names the variable, optionally followed by an "=" token and a local-variable-initializer that gives the initial value of the variable. Paragraph 41 The value of a local variable is obtained in an expression using a simple-name (§14.5.2), and the value of a local variable is modified using an assignment (§14.13). 2 A local variable must be definitely assigned (§12.3) at each location where its value is obtained. Paragraph 51 The scope of a local variable declared in a local-variable-declaration is the block in which the declaration occurs. 2 It is an error to refer to a local variable in a textual position that precedes the local-variable-declarator of the local variable. 3 Within the scope of a local variable, it is a compile-time error to declare another local variable or constant with the same name. Paragraph 61 A local variable declaration that declares multiple variables is equivalent to multiple declarations of single variables with the same type. 2 Furthermore, a variable initializer in a local variable declaration corresponds exactly to an assignment statement that is inserted immediately after the declaration. [Example: The example
void F() {  
   int x = 1, y, z = x * 2;  
}  
corresponds exactly to
void F() {  
   int x; x = 1;  
   int y;  
   int z; z = x * 2;  
}  
end example]
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS