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:
Func<int, int, int> add = (a, b) => a + b;int three = add(1, 2);
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
arg2. How this looks in Visual Studio is shown in Figure 17.10.