Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
CSharp 4 Language Specification.doc
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
2.51 Mб
Скачать

7. Expressions 137

7.1 Expression classifications 137

7.1.1 Values of expressions 138

7.2 Static and Dynamic Binding 138

7.2.1 Binding-time 139

7.2.2 Dynamic binding 139

7.2.3 Types of constituent expressions 139

7.3 Operators 140

7.3.1 Operator precedence and associativity 140

7.3.2 Operator overloading 141

7.3.3 Unary operator overload resolution 142

7.3.4 Binary operator overload resolution 143

7.3.5 Candidate user-defined operators 143

7.3.6 Numeric promotions 143

7.3.6.1 Unary numeric promotions 144

7.3.6.2 Binary numeric promotions 144

7.3.7 Lifted operators 145

7.4 Member lookup 145

7.4.1 Base types 147

7.5 Function members 147

7.5.1 Argument lists 149

7.5.1.1 Corresponding parameters 150

7.5.1.2 Run-time evaluation of argument lists 151

7.5.2 Type inference 153

7.5.2.1 The first phase 154

7.5.2.2 The second phase 154

7.5.2.3 Input types 154

7.5.2.4 Output types 154

7.5.2.5 Dependence 154

7.5.2.6 Output type inferences 154

7.5.2.7 Explicit parameter type inferences 155

7.5.2.8 Exact inferences 155

7.5.2.9 Lower-bound inferences 155

7.5.2.10 Upper-bound inferences 156

7.5.2.11 Fixing 156

7.5.2.12 Inferred return type 156

7.5.2.13 Type inference for conversion of method groups 158

7.5.2.14 Finding the best common type of a set of expressions 158

7.5.3 Overload resolution 158

7.5.3.1 Applicable function member 159

7.5.3.2 Better function member 159

7.5.3.3 Better conversion from expression 160

7.5.3.4 Better conversion from type 161

7.5.3.5 Better conversion target 161

7.5.3.6 Overloading in generic classes 161

7.5.4 Compile-time checking of dynamic overload resolution 162

7.5.5 Function member invocation 162

7.5.5.1 Invocations on boxed instances 163

7.6 Primary expressions 163

7.6.1 Literals 164

7.6.2 Simple names 164

7.6.2.1 Invariant meaning in blocks 165

7.6.3 Parenthesized expressions 166

7.6.4 Member access 167

7.6.4.1 Identical simple names and type names 168

7.6.4.2 Grammar ambiguities 169

7.6.5 Invocation expressions 170

7.6.5.1 Method invocations 170

7.6.5.2 Extension method invocations 171

7.6.5.3 Delegate invocations 174

7.6.6 Element access 174

7.6.6.1 Array access 175

7.6.6.2 Indexer access 175

7.6.7 This access 176

7.6.8 Base access 177

7.6.9 Postfix increment and decrement operators 177

7.6.10 The new operator 178

7.6.10.1 Object creation expressions 178

7.6.10.2 Object initializers 180

7.6.10.3 Collection initializers 182

7.6.10.4 Array creation expressions 183

7.6.10.5 Delegate creation expressions 185

7.6.10.6 Anonymous object creation expressions 186

7.6.11 The typeof operator 188

7.6.12 The checked and unchecked operators 190

7.6.13 Default value expressions 192

7.6.14 Anonymous method expressions 192

7.7 Unary operators 192

7.7.1 Unary plus operator 193

7.7.2 Unary minus operator 193

7.7.3 Logical negation operator 193

7.7.4 Bitwise complement operator 194

7.7.5 Prefix increment and decrement operators 194

7.7.6 Cast expressions 195

7.8 Arithmetic operators 195

7.8.1 Multiplication operator 196

7.8.2 Division operator 197

7.8.3 Remainder operator 198

7.8.4 Addition operator 199

7.8.5 Subtraction operator 200

7.9 Shift operators 202

7.10 Relational and type-testing operators 203

7.10.1 Integer comparison operators 204

7.10.2 Floating-point comparison operators 205

7.10.3 Decimal comparison operators 206

7.10.4 Boolean equality operators 206

7.10.5 Enumeration comparison operators 206

7.10.6 Reference type equality operators 206

7.10.7 String equality operators 208

7.10.8 Delegate equality operators 208

7.10.9 Equality operators and null 209

7.10.10 The is operator 209

7.10.11 The as operator 209

7.11 Logical operators 210

7.11.1 Integer logical operators 211

7.11.2 Enumeration logical operators 211

7.11.3 Boolean logical operators 211

7.11.4 Nullable boolean logical operators 212

7.12 Conditional logical operators 212

7.12.1 Boolean conditional logical operators 213

7.12.2 User-defined conditional logical operators 213

7.13 The null coalescing operator 214

7.14 Conditional operator 214

7.15 Anonymous function expressions 215

7.15.1 Anonymous function signatures 217

7.15.2 Anonymous function bodies 217

7.15.3 Overload resolution 218

7.15.4 Anonymous functions and dynamic binding 219

7.15.5 Outer variables 219

7.15.5.1 Captured outer variables 219

7.15.5.2 Instantiation of local variables 220

7.15.6 Evaluation of anonymous function expressions 222

7.16 Query expressions 222

7.16.1 Ambiguities in query expressions 223

7.16.2 Query expression translation 223

7.16.2.1 Select and groupby clauses with continuations 224

7.16.2.2 Explicit range variable types 224

7.16.2.3 Degenerate query expressions 225

7.16.2.4 From, let, where, join and orderby clauses 225

7.16.2.5 Select clauses 229

7.16.2.6 Groupby clauses 229

7.16.2.7 Transparent identifiers 230

7.16.3 The query expression pattern 231

7.17 Assignment operators 232

7.17.1 Simple assignment 233

7.17.2 Compound assignment 235

7.17.3 Event assignment 236

7.18 Expression 236

7.19 Constant expressions 237

7.20 Boolean expressions 238

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]