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.15–14.17 is in the DelegateRemoval directory.
DelegateCallback ad = new DelegateCallback(ACallback); DelegateCallback bd = new DelegateCallback(BCallback); DelegateCallback cd = new DelegateCallback(CCallback); ...