O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

14.3. Combining delegates

If each delegate instance is only good for encapsulating one method, then its use will be very limited. The good news is that you can have one delegate instance encapsulating multiple methods in its invocation list. [6] It does not matter whether the methods in a delegate instance's invocation list are static or not. It also does not matter if these methods are totally unrelated and belong to classes in unrelated namespaces. All that matters is that each method matches the delegate type's return type and parameters.

[6] Some books use the terms 'composite delegate' or 'multi-cast delegate' to refer to delegate instances with more than one method in their invocation list.

You can use the + and - operators (as well as += ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required