1 What do you do when you just don??™t have a value? 113
Why value type variables can??™t be null 113 ?– Patterns
for representing null values in C# 1 114
4.2 System.Nullable
and System.Nullable 115
Introducing Nullable 116 ?– Boxing and
unboxing 118 ?– Equality of Nullable
instances 119 ?– Support from the nongeneric
Nullable class 119
4.3 C# 2??™s syntactic sugar for nullable types 120
The ? modifier 121 ?– Assigning and comparing with
null 122 ?– Nullable conversions and operators 124
Nullable logic 127 ?– The null coalescing operator 128
4.4 Novel uses of nullable types 131
Trying an operation without using output
parameters 131 ?– Painless comparisons with the null
coalescing operator 133 ?– Summary 136
5 Fast-tracked delegates 137
5.1 Saying goodbye to awkward delegate syntax 138
5.2 Method group conversions 140
5.3 Covariance and contravariance 141
CONTENTS xii
5.4 Inline delegate actions with anonymous methods 144
Starting simply: acting on a parameter 145 ?– Returning
values from anonymous methods 147 ?– Ignoring delegate
parameters 149
5.5 Capturing variables in anonymous methods 150
Defining closures and different types of variables 151
Examining the behavior of captured variables 152 ?– What??™s the
point of captured variables? 153 ?– The extended lifetime of
captured variables 154 ?– Local variable instantiations 155
Mixtures of shared and distinct variables 157 ?– Captured
variable guidelines and summary 158
5.
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