O'Reilly logo

Applied Microsoft® .NET Framework Programming by Jeffrey Richter

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

Delegates and Reflection

So far in this chapter, the use of delegates has required that the developer know up front the prototype of the method that is to be called back. For example, if feedback is a variable that references a Feedback delegate, then to invoke the delegate, the code would look like this:

feedback(items[item], item, items.Length);

As you can see, the developer must know when coding how many parameters the callback method requires and the types of those parameters. Fortunately, the developer almost always has this information and so writing code like the preceding isn’t a problem.

In some rare scenarios, however, the developer doesn’t have this information at compile time. I showed an example of this in Chapter 11 when I discussed ...

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