in principle:
1. The essence of a delegation is a pointer, a function pointer. Just get the first address of the function;
C#'s delegation adds security, which is reflected in the type detection of the function instruction block referenced by the function pointer, such as return value, parameter type, and number of parameters.
When a function pointer in C is assigned a value (in C#, it is when the delegate is instantiated, because the C# backend handles the delegate as a class and encapsulates it) whether the assigned value satisfies the various conditions of the type (return Value, parameter type, number of parameters) are not checked, and the guarantee is given by the user, and C# will compile and prompt it.
2. The process of delegate instantiation, that is, the process of constructing the delegate object, is to assign the memory address of an existing function code instruction block (static function, non-static member function of the instance) to the delegate; This assignment process is what the delegated constructor does. Therefore, the delegated constructor must have a parameter. This parameter is processed by the system in the background, which is the function pointer that satisfies the type check, and the type to be checked (return value, parameter Type, number of parameters) are all given when declaring and defining the delegate.
3. Two methods of delegate instantiation:
1) A a = new A (static method name/instance. method name);
2) A a = static method name/instance.method name;
Two methods called by delegates:
1) a.Invoke()
2)a()
The method used to construct a delegate can be a static method or a member function of an instantiated object. The essence is that this code instruction has been compiled, memory has been allocated, and the parameters passed to the delegate (essentially, the header of this instruction data) Address) is valid and meaningful. From this perspective, natural static methods and instance methods can be used to construct and create delegate instances.