About C # delegated application and summary,
What is delegation?Official explanation
A delegate is a type that defines the method signature. When instantiating a delegate, You can associate its instance with any method with a compatible signature. You can call a method by entrusting an instance.
Personal UnderstandingA delegate is an object that holds one or more methods. The object can be executed and can be passed.
Usage
First, create a class or multiple classes and use the keyword delegat to create a delegate instantiation class. Use the delegate class to create a delegate object and assign a value to the object. the "+" symbol can hold multiple methods to call the delegate call method, which is similar to the function class. I will write it in this case: // namespace using System; using System. collections. generic; using System. linq; using System. text; using System. threading. tasks; namespace ConsoleApp3 // defines two public class dogs {public void play () {Console. writeLine ("Wang") ;}} public class cat {public void play () {Console. writeLine ("meow ") ;}} Class Program {delegate void act (); // defines a delegate Type static void Main (string [] args) {dog = new dog (); // instantiate the object cat = new cat (); act del = dog. play; // define the delegate object del + = cat. play; // hold multiple methods del + = delegate () // lambda expression {Console. write ("what are you doing! ") ;}; Da (); Console. Read ();}}}