5 Summary 253
10 Extension methods 255
10.1 Life before extension methods 256
10.2 Extension method syntax 258
Declaring extension methods 258 ?– Calling
extension methods 259 ?– How extension methods
are found 261 ?– Calling a method on a null
reference 262
10.3 Extension methods in .NET 3.5 263
First steps with Enumerable 263 ?– Filtering with
Where, and chaining method calls together 265 ?– Projections
using the Select method and anonymous types 266 ?– Sorting
using the OrderBy method 267 ?– Business examples
involving chaining 269
10.4 Usage ideas and guidelines 270
???Extending the world??? and making interfaces richer 270
Fluent interfaces 271 ?– Using extension methods
sensibly 272
10.5 Summary 274
11 Query expressions and LINQ to Objects 275
11.1 Introducing LINQ 276
What??™s in a name? 276 ?– Fundamental concepts in
LINQ 277 ?– Defining the sample data model 282
11.2 Simple beginnings: selecting elements 283
Starting with a source and ending with a selection 283
Compiler translations as the basis of query expressions 284
Range variables and nontrivial projections 287
Cast, OfType, and explicitly typed range variables 289
11.3 Filtering and ordering a sequence 290
Filtering using a where clause 290 ?– Degenerate query
expressions 291 ?– Ordering using an orderby clause 292
CONTENTS xv
11.4 Let clauses and transparent identifiers 294
Introducing an intermediate computation with let 295
Transparent identifiers 296
11.
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