C_Shahrp Uv Thuh DoT NET Langz ToT Heer Uv Thuh Zoom Lang Sohrss TekSTs Uv SmahrT Tek Langz Tot Heer

KLihk Heer Tu DownLoad And See Thuh Free PDF Uv Thuh Standard ECMA-334 C# Language Specification Fohr C#.

Standard ECMA-334 C# Language Specification Table of Contents:

Foreword ………………………………………………………………………………………………………………………….. xix
Introduction ………………………………………………………………………………………………………………………. xx
1. Scope ………………………………………………………………………………………………………………………………. 1
2. Conformance ……………………………………………………………………………………………………………………. 3
3. Normative references ………………………………………………………………………………………………………… 5
4. Terms and definitions…………………………………………………………………………………………………………. 7
5. Acronyms and abbreviations ……………………………………………………………………………………………….. 9
6. General description ………………………………………………………………………………………………………….. 11
7. Lexical structure ………………………………………………………………………………………………………………. 13
7.1 Programs …………………………………………………………………………………………………………………………….. 13
7.2 Grammars ……………………………………………………………………………………………………………………………. 13
7.2.1 General …………………………………………………………………………………………………………………………. 13
7.2.2 Grammar notation …………………………………………………………………………………………………………. 13
7.2.3 Lexical grammar …………………………………………………………………………………………………………….. 14
7.2.4 Syntactic grammar …………………………………………………………………………………………………………. 15
7.2.5 Grammar ambiguities …………………………………………………………………………………………………….. 15
7.3 Lexical analysis …………………………………………………………………………………………………………………….. 15
7.3.1 General …………………………………………………………………………………………………………………………. 15
7.3.2 Line terminators …………………………………………………………………………………………………………….. 16
7.3.3 Comments …………………………………………………………………………………………………………………….. 16
7.3.4 White space …………………………………………………………………………………………………………………… 18
7.4 Tokens ………………………………………………………………………………………………………………………………… 18
7.4.1 General …………………………………………………………………………………………………………………………. 18
7.4.2 Unicode character escape sequences ……………………………………………………………………………….. 19
7.4.3 Identifiers ……………………………………………………………………………………………………………………… 19
7.4.4 Keywords ………………………………………………………………………………………………………………………. 21
7.4.5 Literals ………………………………………………………………………………………………………………………….. 22
7.4.5.1 General …………………………………………………………………………………………………………………… 22
7.4.5.2 Boolean literals ………………………………………………………………………………………………………… 22
7.4.5.3 Integer literals …………………………………………………………………………………………………………. 22
7.4.5.4 Real literals ……………………………………………………………………………………………………………… 23
7.4.5.5 Character literals 24
7.4.5.6 String literals 25
7.4.5.7 The null literal 27
7.4.6 Operators and punctuators ……………………………………………………………………………………………… 27
7.5 Pre-processing directives ………………………………………………………………………………………………………. 27
7.5.1 General …………………………………………………………………………………………………………………………. 27
7.5.2 Conditional compilation symbols ……………………………………………………………………………………… 28
7.5.3 Pre-processing expressions ……………………………………………………………………………………………… 29
7.5.4 Definition directives ……………………………………………………………………………………………………….. 29
7.5.5 Conditional compilation directives …………………………………………………………………………………… 30
7.5.6 Diagnostic directives ………………………………………………………………………………………………………. 33
7.5.7 Region directives ……………………………………………………………………………………………………………. 33
ECMA-334
iv
7.5.8 Line directives ……………………………………………………………………………………………………………….. 34
7.5.9 Pragma directives …………………………………………………………………………………………………………… 34
8. Basic concepts…………………………………………………………………………………………………………………. 36
8.1 Application startup ……………………………………………………………………………………………………………….. 36
8.2 Application termination ………………………………………………………………………………………………………… 37
8.3 Declarations…………………………………………………………………………………………………………………………. 37
8.4 Members …………………………………………………………………………………………………………………………….. 40
8.4.1 General …………………………………………………………………………………………………………………………. 40
8.4.2 Namespace members …………………………………………………………………………………………………….. 40
8.4.3 Struct members ……………………………………………………………………………………………………………… 40
8.4.4 Enumeration members …………………………………………………………………………………………………… 40
8.4.5 Class members ………………………………………………………………………………………………………………. 40
8.4.6 Interface members …………………………………………………………………………………………………………. 41
8.4.7 Array members………………………………………………………………………………………………………………. 41
8.4.8 Delegate members …………………………………………………………………………………………………………. 41
8.5 Member access ……………………………………………………………………………………………………………………. 41
8.5.1 General …………………………………………………………………………………………………………………………. 41
8.5.2 Declared accessibility ……………………………………………………………………………………………………… 41
8.5.3 Accessibility domains ……………………………………………………………………………………………………… 42
8.5.4 Protected access ……………………………………………………………………………………………………………. 44
8.5.5 Accessibility constraints ………………………………………………………………………………………………….. 46
8.6 Signatures and overloading ……………………………………………………………………………………………………. 46
8.7 Scopes…………………………………………………………………………………………………………………………………. 48
8.7.1 General …………………………………………………………………………………………………………………………. 48
8.7.2 Name hiding ………………………………………………………………………………………………………………….. 50
8.7.2.1 General …………………………………………………………………………………………………………………… 50
8.7.2.2 Hiding through nesting ……………………………………………………………………………………………… 50
8.7.2.3 Hiding through inheritance ……………………………………………………………………………………….. 51
8.8 Namespace and type names ………………………………………………………………………………………………….. 52
8.8.1 General …………………………………………………………………………………………………………………………. 52
8.8.2 Unqualified names …………………………………………………………………………………………………………. 54
8.8.3 Fully qualified names ……………………………………………………………………………………………………… 54
8.9 Automatic memory management …………………………………………………………………………………………… 55
8.10 Execution order ………………………………………………………………………………………………………………….. 58
9. Types 59
9.1 General Types 59
9.2 Reference Types 59
9.2.1 General Reference Types 59
9.2.2 Class types …………………………………………………………………………………………………………………….. 60
9.2.3 The object type ……………………………………………………………………………………………………………… 60
9.2.4 The dynamic type …………………………………………………………………………………………………………… 60
9.2.5 The string type ………………………………………………………………………………………………………………. 61
9.2.6 Interface types ………………………………………………………………………………………………………………. 61
9.2.7 Array types ……………………………………………………………………………………………………………………. 61
9.2.8 Delegate types ………………………………………………………………………………………………………………. 61
9.3 Value types ………………………………………………………………………………………………………………………….. 61
9.3.1 General …………………………………………………………………………………………………………………………. 61
9.3.2 The System.ValueType type …………………………………………………………………………………………….. 62
9.3.3 Default constructors ………………………………………………………………………………………………………. 62
9.3.4 Struct types …………………………………………………………………………………………………………………… 63
9.3.5 Simple types ………………………………………………………………………………………………………………….. 63
9.3.6 Integral types ………………………………………………………………………………………………………………… 64
9.3.7 Floating-point types ……………………………………………………………………………………………………….. 65
9.3.8 The decimal type ……………………………………………………………………………………………………………. 66
9.3.9 The bool type ………………………………………………………………………………………………………………… 66
9.3.10 Enumeration types ……………………………………………………………………………………………………….. 66
9.3.11 Nullable value types ……………………………………………………………………………………………………… 67
9.3.12 Boxing and unboxing …………………………………………………………………………………………………….. 67
9.4 Constructed types ………………………………………………………………………………………………………………… 67
9.4.1 General …………………………………………………………………………………………………………………………. 67
9.4.2 Type arguments …………………………………………………………………………………………………………….. 68
9.4.3 Open and closed types ……………………………………………………………………………………………………. 68
9.4.4 Bound and unbound types ………………………………………………………………………………………………. 69
9.4.5 Satisfying constraints ……………………………………………………………………………………………………… 69
9.5 Type parameters ………………………………………………………………………………………………………………….. 70
9.6 Expression tree types ……………………………………………………………………………………………………………. 70
9.7 The dynamic type …………………………………………………………………………………………………………………. 71
10. Variables ………………………………………………………………………………………………………………………. 73
10.1 General ……………………………………………………………………………………………………………………………… 73
10.2 Variable categories ……………………………………………………………………………………………………………… 73
10.2.1 General ……………………………………………………………………………………………………………………….. 73
10.2.2 Static variables …………………………………………………………………………………………………………….. 73
10.2.3 Instance variables…………………………………………………………………………………………………………. 73
10.2.3.1 General …………………………………………………………………………………………………………………. 73
10.2.3.2 Instance variables in classes …………………………………………………………………………………….. 74
10.2.3.3 Instance variables in structs …………………………………………………………………………………….. 74
10.2.4 Array elements …………………………………………………………………………………………………………….. 74
10.2.5 Value parameters …………………………………………………………………………………………………………. 74
10.2.6 Reference parameters ………………………………………………………………………………………………….. 74
10.2.7 Output parameters ………………………………………………………………………………………………………. 75
10.2.8 Local variables ……………………………………………………………………………………………………………… 75
10.3 Default values …………………………………………………………………………………………………………………….. 76
10.4 Definite assignment ……………………………………………………………………………………………………………. 76
10.4.1 General ……………………………………………………………………………………………………………………….. 76
10.4.2 Initially assigned variables …………………………………………………………………………………………….. 77
10.4.3 Initially unassigned variables …………………………………………………………………………………………. 77
10.4.4 Precise rules for determining definite assignment ……………………………………………………………. 77
10.4.4.1 General …………………………………………………………………………………………………………………. 77
10.4.4.2 General rules for statements …………………………………………………………………………………… 78
10.4.4.3 Block statements, checked, and unchecked statements ……………………………………………… 78
10.4.4.4 Expression statements ……………………………………………………………………………………………. 78
10.4.4.5 Declaration statements …………………………………………………………………………………………… 78
10.4.4.6 If statements …………………………………………………………………………………………………………. 79
10.4.4.7 Switch statements ………………………………………………………………………………………………….. 79
10.4.4.8 While statements …………………………………………………………………………………………………… 79
10.4.4.9 Do statements ……………………………………………………………………………………………………….. 79
10.4.4.10 For statements …………………………………………………………………………………………………….. 80
10.4.4.11 Break, continue, and goto statements …………………………………………………………………….. 80
10.4.4.12 Throw statements ………………………………………………………………………………………………… 80
10.4.4.13 Return statements ……………………………………………………………………………………………….. 80
10.4.4.14 Try-catch statements ……………………………………………………………………………………………. 80
ECMA-334
vi
10.4.4.15 Try-finally statements …………………………………………………………………………………………… 81
10.4.4.16 Try-catch-finally statements ………………………………………………………………………………….. 81
10.4.4.17 Foreach statements ……………………………………………………………………………………………… 82
10.4.4.18 Using statements …………………………………………………………………………………………………. 82
10.4.4.19 Lock statements …………………………………………………………………………………………………… 82
10.4.4.20 Yield statements …………………………………………………………………………………………………… 82
10.4.4.21 General rules for constant expressions …………………………………………………………………… 83
10.4.4.22 General rules for simple expressions ………………………………………………………………………. 83
10.4.4.23 General rules for expressions with embedded expressions ……………………………………….. 83
10.4.4.24 Invocation expressions and object creation expressions …………………………………………… 84
10.4.4.25 Simple assignment expressions ……………………………………………………………………………… 84
10.4.4.26 && expressions ……………………………………………………………………………………………………. 85
10.4.4.27 || expressions ……………………………………………………………………………………………………… 85
10.4.4.28 ! expressions ……………………………………………………………………………………………………….. 86
10.4.4.29 ?? expressions ……………………………………………………………………………………………………… 86
10.4.4.30 ?: expressions ………………………………………………………………………………………………………. 87
10.4.4.31 Anonymous functions …………………………………………………………………………………………… 87
10.5 Variable references …………………………………………………………………………………………………………….. 88
10.6 Atomicity of variable references …………………………………………………………………………………………… 88
11. Conversions ………………………………………………………………………………………………………………….. 89
11.1 General ……………………………………………………………………………………………………………………………… 89
11.2 Implicit conversions…………………………………………………………………………………………………………….. 89
11.2.1 General ……………………………………………………………………………………………………………………….. 89
11.2.2 Identity conversion ………………………………………………………………………………………………………. 90
11.2.3 Implicit numeric conversions …………………………………………………………………………………………. 90
11.2.4 Implicit enumeration conversions ………………………………………………………………………………….. 90
11.2.5 Implicit nullable conversions………………………………………………………………………………………….. 90
11.2.6 Null literal conversions ………………………………………………………………………………………………….. 90
11.2.7 Implicit reference conversions ……………………………………………………………………………………….. 90
11.2.8 Boxing conversions……………………………………………………………………………………………………….. 91
11.2.9 Implicit dynamic conversions …………………………………………………………………………………………. 93
11.2.10 Implicit constant expression conversions ………………………………………………………………………. 93
11.2.11 Implicit conversions involving type parameters ……………………………………………………………… 93
11.2.12 User-defined implicit conversions ………………………………………………………………………………… 94
11.2.13 Anonymous function conversions and method group conversions …………………………………… 94
11.3 Explicit conversions …………………………………………………………………………………………………………….. 94
11.3.1 General ……………………………………………………………………………………………………………………….. 94
11.3.2 Explicit numeric conversions ………………………………………………………………………………………….. 95
11.3.3 Explicit enumeration conversions …………………………………………………………………………………… 96
11.3.4 Explicit nullable conversions ………………………………………………………………………………………….. 97
11.3.5 Explicit reference conversions ……………………………………………………………………………………….. 97
11.3.6 Unboxing conversions …………………………………………………………………………………………………… 98
11.3.7 Explicit dynamic conversions …………………………………………………………………………………………. 98
11.3.8 Explicit conversions involving type parameters ………………………………………………………………… 99
11.3.9 User-defined explicit conversions …………………………………………………………………………………. 100
11.4 Standard conversions ………………………………………………………………………………………………………… 100
11.4.1 General ……………………………………………………………………………………………………………………… 100
11.4.2 Standard implicit conversions ………………………………………………………………………………………. 100
11.4.3 Standard explicit conversions ………………………………………………………………………………………. 100
11.5 User-defined conversions…………………………………………………………………………………………………… 101
11.5.1 General ……………………………………………………………………………………………………………………… 101
Table of Contents
vii
11.5.2 Permitted user-defined conversions ……………………………………………………………………………… 101
11.5.3 Evaluation of user-defined conversions …………………………………………………………………………. 101
11.5.4 User-defined implicit conversions ………………………………………………………………………………… 102
11.5.5 User-defined explicit conversions …………………………………………………………………………………. 103
11.6 Conversions involving nullable types …………………………………………………………………………………… 104
11.6.1 Nullable Conversions…………………………………………………………………………………………………… 104
11.6.2 Lifted conversions ………………………………………………………………………………………………………. 104
11.7 Anonymous function conversions ……………………………………………………………………………………….. 105
11.7.1 General ……………………………………………………………………………………………………………………… 105
11.7.2 Evaluation of anonymous function conversions to delegate types ……………………………………. 107
11.7.3 Evaluation of anonymous function conversions to expression tree types ………………………….. 107
11.8 Method group conversions ………………………………………………………………………………………………… 107
12. Expressions …………………………………………………………………………………………………………………. 111
12.1 General ……………………………………………………………………………………………………………………………. 111
12.2 Expression classifications …………………………………………………………………………………………………… 111
12.2.1 General ……………………………………………………………………………………………………………………… 111
12.2.2 Values of expressions ………………………………………………………………………………………………….. 112
12.3 Static and Dynamic Binding ………………………………………………………………………………………………… 112
12.3.1 General ……………………………………………………………………………………………………………………… 112
12.3.2 Binding-time ………………………………………………………………………………………………………………. 113
12.3.3 Dynamic binding …………………………………………………………………………………………………………. 113
12.3.4 Types of subexpressions ……………………………………………………………………………………………… 113
12.4 Operators ………………………………………………………………………………………………………………………… 114
12.4.1 General ……………………………………………………………………………………………………………………… 114
12.4.2 Operator precedence and associativity …………………………………………………………………………. 114
12.4.3 Operator overloading ………………………………………………………………………………………………….. 115
12.4.4 Unary operator overload resolution ……………………………………………………………………………… 117
12.4.5 Binary operator overload resolution……………………………………………………………………………… 117
12.4.6 Candidate user-defined operators ………………………………………………………………………………… 117
12.4.7 Numeric promotions …………………………………………………………………………………………………… 118
12.4.7.1 General ……………………………………………………………………………………………………………….. 118
12.4.7.2 Unary numeric promotions ……………………………………………………………………………………. 118
12.4.7.3 Binary numeric promotions …………………………………………………………………………………… 118
12.4.8 Lifted operators ………………………………………………………………………………………………………….. 119
12.5 Member lookup ………………………………………………………………………………………………………………… 120
12.5.1 General ……………………………………………………………………………………………………………………… 120
12.5.2 Base types …………………………………………………………………………………………………………………. 121
12.6 Function members ……………………………………………………………………………………………………………. 121
12.6.1 General ……………………………………………………………………………………………………………………… 121
12.6.2 Argument lists ……………………………………………………………………………………………………………. 124
12.6.2.1 General ……………………………………………………………………………………………………………….. 124
12.6.2.2 Corresponding parameters ……………………………………………………………………………………. 125
12.6.2.3 Run-time evaluation of argument lists…………………………………………………………………….. 125
12.6.3 Type inference……………………………………………………………………………………………………………. 127
12.6.3.1 General ……………………………………………………………………………………………………………….. 127
12.6.3.2 The first phase ……………………………………………………………………………………………………… 128
12.6.3.3 The second phase …………………………………………………………………………………………………. 128
12.6.3.4 Input types ………………………………………………………………………………………………………….. 128
12.6.3.5 Output types ……………………………………………………………………………………………………….. 129
12.6.3.6 Dependence ………………………………………………………………………………………………………… 129
12.6.3.7 Output type inferences …………………………………………………………………………………………. 129
ECMA-334
viii
12.6.3.8 Explicit parameter type inferences …………………………………………………………………………. 129
12.6.3.9 Exact inferences …………………………………………………………………………………………………… 129
12.6.3.10 Lower-bound inferences ……………………………………………………………………………………… 129
12.6.3.11 Upper-bound inferences ……………………………………………………………………………………… 130
12.6.3.12 Fixing ………………………………………………………………………………………………………………… 130
12.6.3.13 Inferred return type ……………………………………………………………………………………………. 131
12.6.3.14 Type inference for conversion of method groups …………………………………………………… 132
12.6.3.15 Finding the best common type of a set of expressions ……………………………………………. 132
12.6.4 Overload resolution ……………………………………………………………………………………………………. 133
12.6.4.1 General ……………………………………………………………………………………………………………….. 133
12.6.4.2 Applicable function member ………………………………………………………………………………….. 133
12.6.4.3 Better function member ……………………………………………………………………………………….. 134
12.6.4.4 Better conversion from expression …………………………………………………………………………. 135
12.6.4.5 Better conversion from type ………………………………………………………………………………….. 135
12.6.4.6 Better conversion target ……………………………………………………………………………………….. 135
12.6.4.7 Overloading in generic classes ……………………………………………………………………………….. 136
12.6.5 Compile-time checking of dynamic member invocation ………………………………………………….. 136
12.6.6 Function member invocation ……………………………………………………………………………………….. 137
12.6.6.1 General ……………………………………………………………………………………………………………….. 137
12.6.6.2 Invocations on boxed instances ……………………………………………………………………………… 138
12.7 Primary expressions ………………………………………………………………………………………………………….. 138
12.7.1 General ……………………………………………………………………………………………………………………… 138
12.7.2 Literals ………………………………………………………………………………………………………………………. 139
12.7.3 Simple names …………………………………………………………………………………………………………….. 139
12.7.3.1 General ……………………………………………………………………………………………………………….. 139
12.7.3.2 Invariant meaning in blocks …………………………………………………………………………………… 141
12.7.4 Parenthesized expressions …………………………………………………………………………………………… 141
12.7.5 Member access ………………………………………………………………………………………………………….. 142
12.7.5.1 General ……………………………………………………………………………………………………………….. 142
12.7.5.2 Identical simple names and type names ………………………………………………………………….. 143
12.7.6 Invocation expressions ………………………………………………………………………………………………… 144
12.7.6.1 General ……………………………………………………………………………………………………………….. 144
12.7.6.2 Method invocations ……………………………………………………………………………………………… 145
12.7.6.3 Extension method invocations ……………………………………………………………………………….. 146
12.7.6.4 Delegate invocations …………………………………………………………………………………………….. 148
12.7.7 Element access …………………………………………………………………………………………………………… 149
12.7.7.1 General ……………………………………………………………………………………………………………….. 149
12.7.7.2 Array access …………………………………………………………………………………………………………. 149
12.7.7.3 Indexer access ……………………………………………………………………………………………………… 150
12.7.8 This access …………………………………………………………………………………………………………………. 150
12.7.9 Base access ………………………………………………………………………………………………………………… 151
12.7.10 Postfix increment and decrement operators ………………………………………………………………… 152
12.7.11 The new operator …………………………………………………………………………………………………….. 153
12.7.11.1 General ……………………………………………………………………………………………………………… 153
12.7.11.2 Object creation expressions …………………………………………………………………………………. 153
12.7.11.3 Object initializers ………………………………………………………………………………………………… 154
12.7.11.4 Collection initializers …………………………………………………………………………………………… 156
12.7.11.5 Array creation expressions …………………………………………………………………………………… 157
12.7.11.6 Delegate creation expressions ……………………………………………………………………………… 159
12.7.11.7 Anonymous object creation expressions ……………………………………………………………….. 161
12.7.12 The typeof operator ………………………………………………………………………………………………….. 162
Table of Contents
ix
12.7.13 The sizeof operator …………………………………………………………………………………………………… 164
12.7.14 The checked and unchecked operators ……………………………………………………………………….. 164
12.7.15 Default value expressions ………………………………………………………………………………………….. 166
12.7.16 Anonymous method expressions ………………………………………………………………………………… 167
12.8 Unary operators ……………………………………………………………………………………………………………….. 167
12.8.1 General ……………………………………………………………………………………………………………………… 167
12.8.2 Unary plus operator ……………………………………………………………………………………………………. 167
12.8.3 Unary minus operator …………………………………………………………………………………………………. 168
12.8.4 Logical negation operator ……………………………………………………………………………………………. 168
12.8.5 Bitwise complement operator ……………………………………………………………………………………… 168
12.8.6 Prefix increment and decrement operators …………………………………………………………………… 169
12.8.7 Cast expressions …………………………………………………………………………………………………………. 170
12.8.8 Await expressions ………………………………………………………………………………………………………. 170
12.8.8.1 General ……………………………………………………………………………………………………………….. 170
12.8.8.2 Awaitable expressions …………………………………………………………………………………………… 171
12.8.8.3 Classification of await expressions ………………………………………………………………………….. 171
12.8.8.4 Run-time evaluation of await expressions ……………………………………………………………….. 171
12.9 Arithmetic operators …………………………………………………………………………………………………………. 172
12.9.1 General ……………………………………………………………………………………………………………………… 172
12.9.2 Multiplication operator ……………………………………………………………………………………………….. 172
12.9.3 Division operator ………………………………………………………………………………………………………… 173
12.9.4 Remainder operator ……………………………………………………………………………………………………. 174
12.9.5 Addition operator……………………………………………………………………………………………………….. 175
12.9.6 Subtraction operator …………………………………………………………………………………………………… 177
12.10 Shift operators ………………………………………………………………………………………………………………… 179
12.11 Relational and type-testing operators ……………………………………………………………………………….. 180
12.11.1 General ……………………………………………………………………………………………………………………. 180
12.11.2 Integer comparison operators ……………………………………………………………………………………. 181
12.11.3 Floating-point comparison operators ………………………………………………………………………….. 182
12.11.4 Decimal comparison operators …………………………………………………………………………………… 182
12.11.5 Boolean equality operators………………………………………………………………………………………… 182
12.11.6 Enumeration comparison operators ……………………………………………………………………………. 183
12.11.7 Reference type equality operators ……………………………………………………………………………… 183
12.11.8 String equality operators …………………………………………………………………………………………… 185
12.11.9 Delegate equality operators ………………………………………………………………………………………. 185
12.11.10 Equality operators between nullable value types and the null literal …………………………….. 186
12.11.11 The is operator ……………………………………………………………………………………………………….. 186
12.11.12 The as operator ………………………………………………………………………………………………………. 187
12.12 Logical operators …………………………………………………………………………………………………………….. 187
12.12.1 General ……………………………………………………………………………………………………………………. 187
12.12.2 Integer logical operators ……………………………………………………………………………………………. 188
12.12.3 Enumeration logical operators……………………………………………………………………………………. 188
12.12.4 Boolean logical operators ………………………………………………………………………………………….. 189
12.12.5 Nullable Boolean & and | operators ……………………………………………………………………………. 189
12.13 Conditional logical operators ……………………………………………………………………………………………. 189
12.13.1 General ……………………………………………………………………………………………………………………. 189
12.13.2 Boolean conditional logical operators …………………………………………………………………………. 190
12.13.3 User-defined conditional logical operators ………………………………………………………………….. 190
12.14 The null coalescing operator …………………………………………………………………………………………….. 191
12.15 Conditional operator ……………………………………………………………………………………………………….. 192
12.16 Anonymous function expressions ……………………………………………………………………………………… 192
ECMA-334
x
12.16.1 General ……………………………………………………………………………………………………………………. 192
12.16.2 Anonymous function signatures …………………………………………………………………………………. 194
12.16.3 Anonymous function bodies ………………………………………………………………………………………. 195
12.16.4 Overload resolution ………………………………………………………………………………………………….. 195
12.16.5 Anonymous functions and dynamic binding …………………………………………………………………. 196
12.16.6 Outer variables …………………………………………………………………………………………………………. 196
12.16.6.1 General ……………………………………………………………………………………………………………… 196
12.16.6.2 Captured outer variables …………………………………………………………………………………….. 196
12.16.6.3 Instantiation of local variables ……………………………………………………………………………… 197
12.16.7 Evaluation of anonymous function expressions ……………………………………………………………. 199
12.16.8 Implementation Exmple …………………………………………………………………………………………….. 199
12.17 Query expressions …………………………………………………………………………………………………………… 202
12.17.1 General ……………………………………………………………………………………………………………………. 202
12.17.2 Ambiguities in query expressions ……………………………………………………………………………….. 203
12.17.3 Query expression translation ……………………………………………………………………………………… 203
12.17.3.1 General ……………………………………………………………………………………………………………… 203
12.17.3.2 select and group … by clauses with continuations ………………………………………………….. 204
12.17.3.3 Explicit range variable types ………………………………………………………………………………… 204
12.17.3.4 Degenerate query expressions……………………………………………………………………………… 205
12.17.3.5 From, let, where, join and orderby clauses ……………………………………………………………. 205
12.17.3.6 Select clauses …………………………………………………………………………………………………….. 208
12.17.3.7 Group clauses …………………………………………………………………………………………………….. 209
12.17.3.8 Transparent identifiers ………………………………………………………………………………………… 209
12.17.4 The query-expression pattern …………………………………………………………………………………….. 211
12.18 Assignment operators ……………………………………………………………………………………………………… 212
12.18.1 General ……………………………………………………………………………………………………………………. 212
12.18.2 Simple assignment ……………………………………………………………………………………………………. 212
12.18.3 Compound assignment ……………………………………………………………………………………………… 214
12.18.4 Event assignment ……………………………………………………………………………………………………… 215
12.19 Expression ……………………………………………………………………………………………………………………… 215
12.20 Constant expressions ………………………………………………………………………………………………………. 216
12.21 Boolean expressions ………………………………………………………………………………………………………… 217
13. Statements …………………………………………………………………………………………………………………. 219
13.1 General ……………………………………………………………………………………………………………………………. 219
13.2 End points and reachability ………………………………………………………………………………………………… 219
13.3 Blocks………………………………………………………………………………………………………………………………. 221
13.3.1 General ……………………………………………………………………………………………………………………… 221
13.3.2 Statement lists …………………………………………………………………………………………………………… 221
13.4 The empty statement ………………………………………………………………………………………………………… 222
13.5 Labeled statements …………………………………………………………………………………………………………… 222
13.6 Declaration statements ……………………………………………………………………………………………………… 223
13.6.1 General ……………………………………………………………………………………………………………………… 223
13.6.2 Local variable declarations …………………………………………………………………………………………… 223
13.6.3 Local constant declarations …………………………………………………………………………………………. 224
13.7 Expression statements ………………………………………………………………………………………………………. 225
13.8 Selection statements …………………………………………………………………………………………………………. 225
13.8.1 General ……………………………………………………………………………………………………………………… 225
13.8.2 The if statement …………………………………………………………………………………………………………. 225
13.8.3 The switch statement ………………………………………………………………………………………………….. 226
13.9 Iteration statements………………………………………………………………………………………………………….. 230
13.9.1 General ……………………………………………………………………………………………………………………… 230
Table of Contents
xi
13.9.2 The while statement …………………………………………………………………………………………………… 230
13.9.3 The do statement ……………………………………………………………………………………………………….. 230
13.9.4 The for statement ………………………………………………………………………………………………………. 231
13.9.5 The foreach statement ………………………………………………………………………………………………… 232
13.10 Jump statements …………………………………………………………………………………………………………….. 235
13.10.1 General ……………………………………………………………………………………………………………………. 235
13.10.2 The break statement …………………………………………………………………………………………………. 236
13.10.3 The continue statement …………………………………………………………………………………………….. 236
13.10.4 The goto statement …………………………………………………………………………………………………… 237
13.10.5 The return statement ………………………………………………………………………………………………… 238
13.10.6 The throw statement ………………………………………………………………………………………………… 239
13.11 The try statement ……………………………………………………………………………………………………………. 240
13.12 The checked and unchecked statements ……………………………………………………………………………. 242
13.13 The lock statement ………………………………………………………………………………………………………….. 243
13.14 The using statement ………………………………………………………………………………………………………… 243
13.15 The yield statement…………………………………………………………………………………………………………. 245
14. Namespaces ………………………………………………………………………………………………………………… 247
14.1 General ……………………………………………………………………………………………………………………………. 247
14.2 Compilation units ……………………………………………………………………………………………………………… 247
14.3 Namespace declarations ……………………………………………………………………………………………………. 247
14.4 Extern alias directives ………………………………………………………………………………………………………… 249
14.5 Using directives ………………………………………………………………………………………………………………… 249
14.5.1 General ……………………………………………………………………………………………………………………… 249
14.5.2 Using alias directives …………………………………………………………………………………………………… 250
14.5.3 Using namespace directives …………………………………………………………………………………………. 254
14.6 Namespace member declarations ………………………………………………………………………………………. 255
14.7 Type declarations ……………………………………………………………………………………………………………… 255
14.8 Qualified alias member ……………………………………………………………………………………………………… 256
14.8.1 General ……………………………………………………………………………………………………………………… 256
14.8.2 Uniqueness of aliases ………………………………………………………………………………………………….. 258
15. Classes ……………………………………………………………………………………………………………………….. 259
15.1 General ……………………………………………………………………………………………………………………………. 259
15.2 Class declarations ……………………………………………………………………………………………………………… 259
15.2.1 General ……………………………………………………………………………………………………………………… 259
15.2.2 Class modifiers …………………………………………………………………………………………………………… 259
15.2.2.1 General ……………………………………………………………………………………………………………….. 259
15.2.2.2 Abstract classes ……………………………………………………………………………………………………. 260
15.2.2.3 Sealed classes ………………………………………………………………………………………………………. 260
15.2.2.4 Static classes ………………………………………………………………………………………………………… 261
15.2.3 Type parameters ………………………………………………………………………………………………………… 261
15.2.4 Class base specification ……………………………………………………………………………………………….. 262
15.2.4.1 General ……………………………………………………………………………………………………………….. 262
15.2.4.2 Base classes …………………………………………………………………………………………………………. 262
15.2.4.3 Interface implementations…………………………………………………………………………………….. 264
15.2.5 Type parameter constraints …………………………………………………………………………………………. 265
15.2.6 Class body………………………………………………………………………………………………………………….. 269
15.2.7 Partial declarations …………………………………………………………………………………………………….. 269
15.3 Class members …………………………………………………………………………………………………………………. 271
15.3.1 General ……………………………………………………………………………………………………………………… 271
15.3.2 The instance type ……………………………………………………………………………………………………….. 272
ECMA-334
xii
15.3.3 Members of constructed types …………………………………………………………………………………….. 273
15.3.4 Inheritance ………………………………………………………………………………………………………………… 274
15.3.5 The new modifier ……………………………………………………………………………………………………….. 274
15.3.6 Access modifiers…………………………………………………………………………………………………………. 275
15.3.7 Constituent types ……………………………………………………………………………………………………….. 275
15.3.8 Static and instance members ……………………………………………………………………………………….. 275
15.3.9 Nested types ……………………………………………………………………………………………………………… 276
15.3.9.1 General ……………………………………………………………………………………………………………….. 276
15.3.9.2 Fully qualified name ……………………………………………………………………………………………… 276
15.3.9.3 Declared accessibility ……………………………………………………………………………………………. 276
15.3.9.4 Hiding …………………………………………………………………………………………………………………. 277
15.3.9.5 this access …………………………………………………………………………………………………………… 277
15.3.9.6 Access to private and protected members of the containing type ……………………………… 278
15.3.9.7 Nested types in generic classes ………………………………………………………………………………. 279
15.3.10 Reserved member names ………………………………………………………………………………………….. 280
15.3.10.1 General ……………………………………………………………………………………………………………… 280
15.3.10.2 Member names reserved for properties………………………………………………………………… 280
15.3.10.3 Member names reserved for events ……………………………………………………………………… 281
15.3.10.4 Member names reserved for indexers …………………………………………………………………… 281
15.3.10.5 Member names reserved for finalizers ………………………………………………………………….. 281
15.4 Constants …………………………………………………………………………………………………………………………. 281
15.5 Fields ………………………………………………………………………………………………………………………………. 283
15.5.1 General ……………………………………………………………………………………………………………………… 283
15.5.2 Static and instance fields …………………………………………………………………………………………….. 284
15.5.3 Readonly fields …………………………………………………………………………………………………………… 284
15.5.3.1 General ……………………………………………………………………………………………………………….. 284
15.5.3.2 Using static readonly fields for constants ………………………………………………………………… 284
15.5.3.3 Versioning of constants and static readonly fields ……………………………………………………. 285
15.5.4 Volatile fields ……………………………………………………………………………………………………………… 285
15.5.5 Field initialization ……………………………………………………………………………………………………….. 286
15.5.6 Variable initializers ……………………………………………………………………………………………………… 287
15.5.6.1 General ……………………………………………………………………………………………………………….. 287
15.5.6.2 Static field initialization …………………………………………………………………………………………. 288
15.5.6.3 Instance field initialization …………………………………………………………………………………….. 289
15.6 Methods ………………………………………………………………………………………………………………………….. 289
15.6.1 General ……………………………………………………………………………………………………………………… 289
15.6.2 Method parameters ……………………………………………………………………………………………………. 291
15.6.2.1 General ……………………………………………………………………………………………………………….. 291
15.6.2.2 Value parameters …………………………………………………………………………………………………. 293
15.6.2.3 Reference parameters…………………………………………………………………………………………… 293
15.6.2.4 Output parameters ………………………………………………………………………………………………. 294
15.6.2.5 Parameter arrays ………………………………………………………………………………………………….. 295
15.6.3 Static and instance methods ………………………………………………………………………………………… 297
15.6.4 Virtual methods …………………………………………………………………………………………………………. 297
15.6.5 Override methods ………………………………………………………………………………………………………. 299
15.6.6 Sealed methods ………………………………………………………………………………………………………….. 301
15.6.7 Abstract methods ……………………………………………………………………………………………………….. 302
15.6.8 External methods ……………………………………………………………………………………………………….. 303
15.6.9 Partial methods ………………………………………………………………………………………………………….. 304
15.6.10 Extension methods ……………………………………………………………………………………………………. 306
15.6.11 Method body……………………………………………………………………………………………………………. 307
Table of Contents
xiii
15.7 Properties ………………………………………………………………………………………………………………………… 308
15.7.1 General ……………………………………………………………………………………………………………………… 308
15.7.2 Static and instance properties ……………………………………………………………………………………… 309
15.7.3 Accessors …………………………………………………………………………………………………………………… 309
15.7.4 Automatically implemented properties …………………………………………………………………………. 313
15.7.5 Accessibility ……………………………………………………………………………………………………………….. 314
15.7.6 Virtual, sealed, override, and abstract accessors ……………………………………………………………. 315
15.8 Events ……………………………………………………………………………………………………………………………… 317
15.8.1 General ……………………………………………………………………………………………………………………… 317
15.8.2 Field-like events …………………………………………………………………………………………………………. 319
15.8.3 Event accessors ………………………………………………………………………………………………………….. 320
15.8.4 Static and instance events …………………………………………………………………………………………… 321
15.8.5 Virtual, sealed, override, and abstract accessors ……………………………………………………………. 321
15.9 Indexers …………………………………………………………………………………………………………………………… 322
15.10 Operators ………………………………………………………………………………………………………………………. 325
15.10.1 General ……………………………………………………………………………………………………………………. 325
15.10.2 Unary operators ……………………………………………………………………………………………………….. 326
15.10.3 Binary operators……………………………………………………………………………………………………….. 327
15.10.4 Conversion operators ………………………………………………………………………………………………… 327
15.11 Instance constructors ………………………………………………………………………………………………………. 330
15.11.1 General ……………………………………………………………………………………………………………………. 330
15.11.2 Constructor initializers ………………………………………………………………………………………………. 331
15.11.3 Instance variable initializers ……………………………………………………………………………………….. 331
15.11.4 Constructor execution……………………………………………………………………………………………….. 332
15.11.5 Default constructors …………………………………………………………………………………………………. 333
15.12 Static constructors…………………………………………………………………………………………………………… 334
15.13 Finalizers ………………………………………………………………………………………………………………………… 336
15.14 Iterators …………………………………………………………………………………………………………………………. 337
15.14.1 General ……………………………………………………………………………………………………………………. 337
15.14.2 Enumerator interfaces ………………………………………………………………………………………………. 338
15.14.3 Enumerable interfaces ………………………………………………………………………………………………. 338
15.14.4 Yield type …………………………………………………………………………………………………………………. 338
15.14.5 Enumerator objects…………………………………………………………………………………………………… 338
15.14.5.1 General ……………………………………………………………………………………………………………… 338
15.14.5.2 The MoveNext method ……………………………………………………………………………………….. 339
15.14.5.3 The Current property ………………………………………………………………………………………….. 340
15.14.5.4 The Dispose method …………………………………………………………………………………………… 340
15.14.6 Enumerable objects ………………………………………………………………………………………………….. 340
15.14.6.1 General ……………………………………………………………………………………………………………… 340
15.14.6.2 The GetEnumerator method ………………………………………………………………………………… 341
15.15 Async Functions ………………………………………………………………………………………………………………. 341
15.15.1 General ……………………………………………………………………………………………………………………. 341
15.15.2 Evaluation of a task-returning async function ………………………………………………………………. 341
15.15.3 Evaluation of a void-returning async function ………………………………………………………………. 342
16. Structs ……………………………………………………………………………………………………………………….. 343
16.1 General ……………………………………………………………………………………………………………………………. 343
16.2 Struct declarations ……………………………………………………………………………………………………………. 343
16.2.1 General ……………………………………………………………………………………………………………………… 343
16.2.2 Struct modifiers ………………………………………………………………………………………………………….. 343
16.2.3 Partial modifier ………………………………………………………………………………………………………….. 344
16.2.4 Struct interfaces …………………………………………………………………………………………………………. 344
ECMA-334
xiv
16.2.5 Struct body ………………………………………………………………………………………………………………… 344
16.3 Struct members ………………………………………………………………………………………………………………… 344
16.4 Class and struct differences ……………………………………………………………………………………………….. 344
16.4.1 General ……………………………………………………………………………………………………………………… 344
16.4.2 Value semantics …………………………………………………………………………………………………………. 345
16.4.3 Inheritance ………………………………………………………………………………………………………………… 346
16.4.4 Assignment ………………………………………………………………………………………………………………… 346
16.4.5 Default values…………………………………………………………………………………………………………….. 346
16.4.6 Boxing and unboxing …………………………………………………………………………………………………… 347
16.4.7 Meaning of this ………………………………………………………………………………………………………….. 347
16.4.8 Field initializers…………………………………………………………………………………………………………… 348
16.4.9 Constructors ………………………………………………………………………………………………………………. 349
16.4.10 Static constructors ……………………………………………………………………………………………………. 349
16.4.11 Automatically implemented properties ……………………………………………………………………….. 350
17. Arrays ………………………………………………………………………………………………………………………… 351
17.1 General ……………………………………………………………………………………………………………………………. 351
17.2 Array types ………………………………………………………………………………………………………………………. 351
17.2.1 General ……………………………………………………………………………………………………………………… 351
17.2.2 The System.Array type ………………………………………………………………………………………………… 351
17.2.3 Arrays and the generic collection interfaces ………………………………………………………………….. 352
17.3 Array creation …………………………………………………………………………………………………………………… 353
17.4 Array element access ………………………………………………………………………………………………………… 353
17.5 Array members …………………………………………………………………………………………………………………. 353
17.6 Array covariance ……………………………………………………………………………………………………………….. 353
17.7 Array initializers ………………………………………………………………………………………………………………… 354
18. Interfaces ……………………………………………………………………………………………………………………. 357
18.1 General ……………………………………………………………………………………………………………………………. 357
18.2 Interface declarations ……………………………………………………………………………………………………….. 357
18.2.1 General ……………………………………………………………………………………………………………………… 357
18.2.2 Interface modifiers ……………………………………………………………………………………………………… 357
18.2.3 Variant type parameter lists ………………………………………………………………………………………… 358
18.2.3.1 General ……………………………………………………………………………………………………………….. 358
18.2.3.2 Variance safety …………………………………………………………………………………………………….. 358
18.2.3.3 Variance conversion ……………………………………………………………………………………………… 359
18.2.4 Base interfaces …………………………………………………………………………………………………………… 359
18.3 Interface body ………………………………………………………………………………………………………………….. 360
18.4 Interface members ……………………………………………………………………………………………………………. 360
18.4.1 General ……………………………………………………………………………………………………………………… 360
18.4.2 Interface methods ………………………………………………………………………………………………………. 361
18.4.3 Interface properties ……………………………………………………………………………………………………. 362
18.4.4 Interface events …………………………………………………………………………………………………………. 362
18.4.5 Interface indexers ………………………………………………………………………………………………………. 362
18.4.6 Interface member access …………………………………………………………………………………………….. 363
18.5 Qualified interface member names …………………………………………………………………………………….. 364
18.6 Interface implementations …………………………………………………………………………………………………. 365
18.6.1 General ……………………………………………………………………………………………………………………… 365
18.6.2 Explicit interface member implementations ………………………………………………………………….. 366
18.6.3 Uniqueness of implemented interfaces …………………………………………………………………………. 368
18.6.4 Implementation of generic methods …………………………………………………………………………….. 369
18.6.5 Interface mapping ………………………………………………………………………………………………………. 370
Table of Contents
xv
18.6.6 Interface implementation inheritance …………………………………………………………………………… 372
18.6.7 Interface re-implementation ……………………………………………………………………………………….. 374
18.6.8 Abstract classes and interfaces …………………………………………………………………………………….. 375
19. Enums ………………………………………………………………………………………………………………………… 377
19.1 General ……………………………………………………………………………………………………………………………. 377
19.2 Enum declarations …………………………………………………………………………………………………………….. 377
19.3 Enum modifiers ………………………………………………………………………………………………………………… 377
19.4 Enum members ………………………………………………………………………………………………………………… 378
19.5 The System.Enum type ………………………………………………………………………………………………………. 380
19.6 Enum values and operations ………………………………………………………………………………………………. 380
20. Delegates ……………………………………………………………………………………………………………………. 381
20.1 General ……………………………………………………………………………………………………………………………. 381
20.2 Delegate declarations………………………………………………………………………………………………………… 381
20.3 Delegate members ……………………………………………………………………………………………………………. 382
20.4 Delegate compatibility ………………………………………………………………………………………………………. 382
20.5 Delegate instantiation ……………………………………………………………………………………………………….. 383
20.6 Delegate invocation ………………………………………………………………………………………………………….. 385
21. Exceptions ………………………………………………………………………………………………………………….. 389
21.1 General ……………………………………………………………………………………………………………………………. 389
21.2 Causes of exceptions …………………………………………………………………………………………………………. 389
21.3 The System.Exception class ………………………………………………………………………………………………… 389
21.4 How exceptions are handled ………………………………………………………………………………………………. 389
21.5 Common exception classes ………………………………………………………………………………………………… 390
22. Attributes …………………………………………………………………………………………………………………… 391
22.1 General ……………………………………………………………………………………………………………………………. 391
22.2 Attribute classes ……………………………………………………………………………………………………………….. 391
22.2.1 General ……………………………………………………………………………………………………………………… 391
22.2.2 Attribute usage ………………………………………………………………………………………………………….. 391
22.2.3 Positional and named parameters ………………………………………………………………………………… 393
22.2.4 Attribute parameter types …………………………………………………………………………………………… 393
22.3 Attribute specification ……………………………………………………………………………………………………….. 394
22.4 Attribute instances ……………………………………………………………………………………………………………. 399
22.4.1 General ……………………………………………………………………………………………………………………… 399
22.4.2 Compilation of an attribute …………………………………………………………………………………………. 399
22.4.3 Run-time retrieval of an attribute instance ……………………………………………………………………. 400
22.5 Reserved attributes …………………………………………………………………………………………………………… 401
22.5.1 General ……………………………………………………………………………………………………………………… 401
22.5.2 The AttributeUsage attribute ……………………………………………………………………………………….. 401
22.5.3 The Conditional attribute …………………………………………………………………………………………….. 401
22.5.3.1 General ……………………………………………………………………………………………………………….. 401
22.5.3.2 Conditional methods …………………………………………………………………………………………….. 401
22.5.3.3 Conditional attribute classes ………………………………………………………………………………….. 404
22.5.4 The Obsolete attribute ………………………………………………………………………………………………… 405
22.5.5 Caller-info attributes …………………………………………………………………………………………………… 405
22.5.5.1 General ……………………………………………………………………………………………………………….. 405
22.5.5.2 The CallerLineNumber attribute …………………………………………………………………………….. 406
22.5.5.3 The CallerFilePath attribute …………………………………………………………………………………… 407
22.5.5.4 The CallerMemberName attribute …………………………………………………………………………. 407
22.6 Attributes for interoperation ……………………………………………………………………………………………… 408
ECMA-334
xvi
23. Unsafe code ………………………………………………………………………………………………………………… 409
23.1 General ……………………………………………………………………………………………………………………………. 409
23.2 Unsafe contexts ………………………………………………………………………………………………………………… 409
23.3 Pointer types ……………………………………………………………………………………………………………………. 411
23.4 Fixed and moveable variables …………………………………………………………………………………………….. 414
23.5 Pointer conversions …………………………………………………………………………………………………………… 415
23.5.1 General ……………………………………………………………………………………………………………………… 415
23.5.2 Pointer arrays …………………………………………………………………………………………………………….. 416
23.6 Pointers in expressions ………………………………………………………………………………………………………. 416
23.6.1 General ……………………………………………………………………………………………………………………… 416
23.6.2 Pointer indirection ……………………………………………………………………………………………………… 417
23.6.3 Pointer member access ……………………………………………………………………………………………….. 417
23.6.4 Pointer element access ……………………………………………………………………………………………….. 418
23.6.5 The address-of operator ……………………………………………………………………………………………… 419
23.6.6 Pointer increment and decrement ……………………………………………………………………………….. 420
23.6.7 Pointer arithmetic ………………………………………………………………………………………………………. 420
23.6.8 Pointer comparison …………………………………………………………………………………………………….. 421
23.6.9 The sizeof operator …………………………………………………………………………………………………….. 421
23.7 The fixed statement ………………………………………………………………………………………………………….. 421
23.8 Fixed-size buffers………………………………………………………………………………………………………………. 424
23.8.1 General ……………………………………………………………………………………………………………………… 424
23.8.2 Fixed-size buffer declarations ………………………………………………………………………………………. 424
23.8.3 Fixed-size buffers in expressions …………………………………………………………………………………… 426
23.8.4 Definite assignment checking ………………………………………………………………………………………. 426
23.9 Stack allocation ………………………………………………………………………………………………………………… 427
Annex A. Grammar ……………………………………………………………………………………………………………. 429
A.1 General ……………………………………………………………………………………………………………………………… 429
A.2 Lexical grammar …………………………………………………………………………………………………………………. 429
A.2.1 Comments …………………………………………………………………………………………………………………… 430
A.2.2 Tokens ………………………………………………………………………………………………………………………… 430
A.2.3 Keywords ……………………………………………………………………………………………………………………. 432
A.2.4 Operators and punctuators …………………………………………………………………………………………… 434
A.2.5 Pre-processing directives ………………………………………………………………………………………………. 434
A.3 Syntactic grammar ……………………………………………………………………………………………………………… 436
A.3.1 Basic concepts ……………………………………………………………………………………………………………… 436
A.3.2 Types ………………………………………………………………………………………………………………………….. 436
A.3.3 Variables …………………………………………………………………………………………………………………….. 437
A.3.4 Expressions …………………………………………………………………………………………………………………. 437
A.3.5 Statements ………………………………………………………………………………………………………………….. 443
A.3.6 Namespaces ………………………………………………………………………………………………………………… 447
A.3.7 Classes ………………………………………………………………………………………………………………………… 448
A.3.8 Structs ………………………………………………………………………………………………………………………… 454
A.3.9 Arrays …………………………………………………………………………………………………………………………. 454
A.3.10 Interfaces ………………………………………………………………………………………………………………….. 454
A.3.11 Enums ………………………………………………………………………………………………………………………. 455
A.3.12 Delegates ………………………………………………………………………………………………………………….. 456
A.3.13 Attributes ………………………………………………………………………………………………………………….. 456
A.4 Grammar extensions for unsafe code ……………………………………………………………………………………. 457
Annex B. Portability issues ………………………………………………………………………………………………….. 461
B.1 General ……………………………………………………………………………………………………………………………… 461
Table of Contents
xvii
B.2 Undefined behavior ……………………………………………………………………………………………………………. 461
B.3 Implementation-defined behavior ………………………………………………………………………………………… 461
B.4 Unspecified behavior ………………………………………………………………………………………………………….. 462
B.5 Other Issues……………………………………………………………………………………………………………………….. 462
Annex C. Standard library …………………………………………………………………………………………………… 463
C.1 General ……………………………………………………………………………………………………………………………… 463
C.2 Standard Library Types defined in ISO/IEC 23271……………………………………………………………………. 463
C.3 Standard Library Types not defined in ISO/IEC 23271:2012 ……………………………………………………… 472
Annex D. Documentation comments …………………………………………………………………………………….. 475
D.1 General ……………………………………………………………………………………………………………………………… 475
D.2 Introduction ………………………………………………………………………………………………………………………. 475
D.3 Recommended tags ……………………………………………………………………………………………………………. 476
D.3.1 General ………………………………………………………………………………………………………………………. 476
D.3.2 <c>……………………………………………………………………………………………………………………………… 477
D.3.3 <code> ……………………………………………………………………………………………………………………….. 477
D.3.4 <example> ………………………………………………………………………………………………………………….. 478
D.3.5 <exception> ………………………………………………………………………………………………………………… 478
D.3.6 <include> ……………………………………………………………………………………………………………………. 478
D.3.7 <list> ………………………………………………………………………………………………………………………….. 479
D.3.8 <para> ………………………………………………………………………………………………………………………… 480
D.3.9 <param> ……………………………………………………………………………………………………………………… 480
D.3.10 <paramref> ……………………………………………………………………………………………………………….. 481
D.3.11 <permission> …………………………………………………………………………………………………………….. 481
D.3.12 <remarks> …………………………………………………………………………………………………………………. 482
D.3.13 <returns> ………………………………………………………………………………………………………………….. 482
D.3.14 <see> ………………………………………………………………………………………………………………………… 482
D.3.15 <seealso> ………………………………………………………………………………………………………………….. 483
D.3.16 <summary> ……………………………………………………………………………………………………………….. 483
D.3.17 <typeparam> …………………………………………………………………………………………………………….. 483
D.3.18 <typeparamref> …………………………………………………………………………………………………………. 484
D.3.19 <value> …………………………………………………………………………………………………………………….. 484
D.4 Processing the documentation file ……………………………………………………………………………………….. 484
D.4.1 General ………………………………………………………………………………………………………………………. 484
D.4.2 ID string format ……………………………………………………………………………………………………………. 484
D.4.3 ID string examples ……………………………………………………………………………………………………….. 486
D.5 An example ……………………………………………………………………………………………………………………….. 489
D.5.1 C# source code …………………………………………………………………………………………………………….. 489
D.5.2 Resulting XML ……………………………………………………………………………………………………………… 491
Annex E. Bibliography ………………………………………………………………………………………………………… 494