Delegates

Learn how to declare, instantiate, and invoke delegates to pass methods as arguments and execute them dynamically.

In C#, we are used to passing data like integers or strings into methods. Delegates allow us to treat behavior as data. By assigning a method to a delegate, you can pass an entire block of logic around your application, allowing methods to execute dynamically provided behaviors.

Delegates are objects that point to methods. They hold references to method definitions, and invoking a delegate executes all methods it references.