6.4. Generic Delegates with Generic Methods

Even though generic delegates allow you to reduce the number of delegates you must declare and they certainly add a modicum of type safety, they do not reduce the number of delegate methods you need. In some respects, this seems to reduce the enthusiasm one might have about the value of generic delegates.

Where generic delegates really shine is when they are used in combination with generic methods. Because generic methods allow you to use type parameters in the signature of the implemented method, your delegate implementations can take on an additional dimension of generality on their own. In leveraging generic methods for your delegates, you may find opportunities to reduce the number of methods needed to meet all the requirements of your delegate's functionality.

For examples of how this can be applied, look at the discussion in Chapter 5, "Generic Methods."

Get Professional .NET 2.0 Generics 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.