Invoking Delegates

Creating delegate instances to refer to particular methods is a necessary step toward invoking those methods through the delegate. In passing, we’ve shown the way to do such invocations repeatedly: They just look like ordinary method calls. For example:

IntelliSense in Visual Studio will obviously give the caller a hand by showing what arguments are expected. Notice that names for those arguments come from the delegate type that’s being used. In the preceding example, we’re using one of the generic Func types, where arguments have names like arg1 and arg2. How this looks in Visual Studio is shown in Figure 17.10.

FIGURE 17.10 Invoking ...

The best content for your career. Discover unlimited learning
on demand for around $1/day.