Prev | Current Page 273 | Next

Jon Skeet

"C# in Depth: What you need to master C# 2 and 3"


So far our two new features (generics and nullable types) have addressed areas
where in C# 1 we occasionally had to hold our noses due to unpleasant code smells.
This pattern continues in the next chapter, where we discuss the enhancements to delegates.
These form an important part of the subtle change of direction of both the C#
language and the .NET Framework, toward a slightly more functional viewpoint. This
emphasis is made even clearer in C# 3, so while we??™re not looking at those features quite
yet, the delegate enhancements in C# 2 act as a bridge between the familiarity of C# 1
and the potentially revolutionary style of C# 3.
137
Fast-tracked delegates
The journey of delegates in C# and .NET is an interesting one, showing remarkable
foresight (or really good luck) on the part of the designers. The conventions suggested
for event handlers in .NET 1.0/1.1 didn??™t make an awful lot of sense??”until
C# 2 showed up. Likewise, the effort put into delegates for C# 2 seems in some ways
out of proportion to how widely used they are??”until you see how pervasive they
are in idiomatic C# 3 code. In other words, it??™s as if the language and platform
designers had a vision of at least the rough direction they would be taking, years
before the destination itself became clear.
Of course, C# 3 is not a ???final destination??? in itself, and we may be seeing further
advances for delegates in the future??”but the differences between C# 1 and
C# 3 in this area are startling.


Pages:
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285