Summary

Delegates are essential tools in the .NET developer’s toolbox. Having a solid understanding of this concept will take you a long way in designing rich and extensible APIs. We’ve illustrated this using .NET Framework libraries such as LINQ, which provides for an incredibly general-purpose and extensible query capability, which was largely made possible thanks to the power of delegates.

Although the concept of functional programming lies, at least conceptually, at the heart of delegates, they can simply be seen as a strongly typed contract describing a single operation. One party acts as a consumer, invoking the delegate to reach out to the functionality provided from the outside. The other party hands out a piece of code that adheres ...

Get C# 5.0 Unleashed 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.