Delegates
Explore how to create and use delegates to reference methods in C#. Understand delegates with static and instance methods, combining delegates, and passing delegates as parameters. This lesson helps you grasp how delegates enable flexible method calls and support generic use cases.
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 ...