Delegate (CLI)

A delegate is a form of type-safe function pointer used by the Common Language Infrastructure (CLI).

To call a method with a delegate successfully, the method signature has to match the DelegateType with the same number of parameters of the same kind (ref, out, value) with the same type (including return type).

When the first delegate has finished, if its chain reference is not null, the next will be invoked, and so on until the list is complete.

This pattern allows an event to have overhead scaling easily from that of a single reference up to dispatch to a list of delegates, and is widely used in the CLI.

[7] This means there is a small added overhead compared to direct method invocations.