The Two Sides of Delegates

Delegates really have two sides to them. One side defines one or more target methods referred to by the (multicast) delegate; the other defines a way to invoke those methods through the delegate. To keep things clear, let’s define a little bit of vocabulary here. We’ll say a target method gets called, whereas a delegate is getting invoked. With those words in place, we can sketch our current understanding of delegates as shown in Figure 18.1.

Image

FIGURE 18.1 Invoking a delegate is an interactive act.

When we look at the picture from left to right, delegates look like very interactive beasts, where the invocation site is ...

Get C# 5.0 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.