Delegate Invocation

Another form of invocation is what I call indirect invocation. This is where delegates come in: Instead of knowing the precise target of an invocation, you know how the target looks in terms of the method signature. In essence, delegates are a way to pass methods around as objects. They form a kind of contract between two parties: a consumer and a provider. An example will clarify things, but we defer more thorough discussion until Chapter 17, “Delegates.”

Let’s consider a “modest” calculator as a trivial (and honestly, contrived) example. What the heck is a modest calculator? It’s one that knows about all commonsense arithmetic operations but also admits it can’t know everything. So, it enables the user of the calculator ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.