June 2003
Intermediate to advanced
624 pages
12h 41m
English
Delegates let you pass methods as parameters. They provide you with another form of polymorphism, because you can assign methods to delegates at runtime, leaving the rest of your code unchanged but calling the methods you specify at runtime. You declare a delegate like this:
[attributes] [modifiers] delegate result-type identifier ([formal-parameters]);
Here are the parts of this statement:
attributes (Optional)— Hold additional declarative information, as we'll see in Chapter 14.
modifiers (Optional)— The allowed modifiers are new and a valid combination of the four access modifiers.
result-type— The result type, which matches the return type of the method.
identifier— The delegate name.
formal-parameters (Optional)— ...