Summary

delegates are used throughout the framework, so they are important. You should incorporate a delegate into your design in the following cases:

  • A single method is called. Unlike an interface, a delegate specifies a single method's signature.

  • A class needs to have multiple implementations of a method. Take, for instance, the qsort example given at the beginning of the chapter. You could very well imagine allowing a compare delegate to be passed to the qsort routine so that different objects could be sorted.

  • You need to have an event-like model for processing in your application. In other words, if your application is designed so that it is more readily implemented using an asynchronous event model, then you should consider delegates and ...

Get .NET Common Language Runtime 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.