Chapter 11. Delegates, Events, and Lambdas

Up to this point in the text, most of the applications you have developed added various bits of code to Main(), which, in some way or another, sent requests to a given object. In Chapter 9, you examined how the interface type can be used to build objects that can "talk back" to the entity that created it. While callback interfaces can be used to configure objects that engage in two-way conversations, the .NET delegate type is the preferred manner to define and respond to callbacks under the .NET platform.

Essentially, the .NET delegate type is a type-safe object that "points to" a method, or if you wish, a list of methods, that can be invoked at a later time. Unlike a traditional C++ function pointer, ...

Get Pro C# 2008 and the .NET 3.5 Platform, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.