...

/

Delegates

Delegates

Create types that can reference and invoke other methods.

Create and call delegates

Delegates are objects that point to methods. In other words, they hold references to method definitions. By calling a delegate, we call all methods the delegate points to.

Delegates can reference methods

Delegates are declared using the delegate keyword. After that, we simply write a method signature with a return type:

delegate void MessagePrinter();

This delegate can point to ...