A good memory is better than a bad pen, write to the impression of a deeper.
Commissioned
- A custom data structure that uses the keyword delegate definition, in the form of a delegate return type delegate name (parameter list), whose return type and argument list need to be consistent with the delegate method, using the procedure to define-declare-initialize-Invoke. The delegate stores the address of the method, which is the reference type, and when a delegate is invoked, the program automatically executes its stored method.
- Delegates are initialized in several ways as the C # version changes
delegate int Mydel (int a,int b); Define the delegate Mydel _mydel; Statement _mydel=new Mydel (FUN1); Initialization Method 1
_MYDEL=FUN1; Initialization method 2_mydel (A, b); Call
- Delegates can use the + = and-= bindings and Unbind methods
_mydel+=fun2; On the basis of the original Fun1 and binding Fun2, sequential execution _mydel-=fun2; To unbind Fun2, there's only Fun1.
C # Delegate