1 Automatically implemented properties 208
8.2 Implicit typing of local variables 210
Using var to declare a local variable 211 ?– Restrictions
on implicit typing 212 ?– Pros and cons of implicit
typing 213 ?– Recommendations 214
8.3 Simplified initialization 215
Defining our sample types 215 ?– Setting simple properties 216
Setting properties on embedded objects 218 ?– Collection
initializers 218 ?– Uses of initialization features 221
8.4 Implicitly typed arrays 223
8.5 Anonymous types 224
First encounters of the anonymous kind 224 ?– Members
of anonymous types 226 ?– Projection initializers 226
What??™s the point? 227
8.6 Summary 228
9 Lambda expressions and expression trees 230
9.1 Lambda expressions as delegates 232
Preliminaries: introducing the Func?¦> delegate types 232
First transformation to a lambda expression 232 ?– Using a
single expression as the body 234 ?– Implicitly typed parameter
lists 234 ?– Shortcut for a single parameter 234
9.2 Simple examples using List
and events 235
Filtering, sorting, and actions on lists 236 ?– Logging in
an event handler 237
9.3 Expression trees 238
Building expression trees programmatically 239 ?– Compiling expression
trees into delegates 240 ?– Converting C# lambda expressions to
expression trees 241 ?– Expression trees at the heart of LINQ 244
CONTENTS xiv
9.4 Changes to type inference and overload resolution 245
Reasons for change: streamlining generic method
calls 246 ?– Inferred return types of anonymous
functions 247 ?– Two-phase type inference 248
Picking the right overloaded method 251
Wrapping up type inference and overload resolution 253
9.
Pages:
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