Removing delegates

Now that you have some understanding of how delegates are compared, you can move on to how delegates are removed from a delegate chain. A delegate chain is simply an array of delegates. To remove a delegate from the chain, the chain is traversed and the first delegate that equals the delegate passed as an argument to Remove will be removed. Some examples best illustrate the concepts regarding delegate removal. The full source code for the code illustrated in Listings 14.1514.17 is in the DelegateRemoval directory.

Listing 14.15. Listing delegates in a delegate Chain
 DelegateCallback ad = new DelegateCallback(ACallback); DelegateCallback bd = new DelegateCallback(BCallback); DelegateCallback cd = new DelegateCallback(CCallback); ...

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.