A. Delegate: A type that defines a method signature and can be associated with any method that has a compatible signature. The so-called compatible method means that the method and the delegate's method signature have the same return type and parameter I syntax:Delegatemethod signature; 1. Method signature is the name of the method, no method body Ii. procedure for using a delegate1. Defining delegates and Delegate objects2. Writing a method to delegate3to pass a delegate's method to the delegate object4. Invoking a delegate method with a delegate Iii. multicast delegates: is to bind multiple methods that have the same method signature as the delegate to the same method1. Use the multicast delegate requirement method to return a type ofvoid. 2. Add a method to the delegate with the "+ =" number, using "-="The number is subtracted from the delegate chain by a method B. Event: is a special case of multicast delegation, the use of events has better security, avoid the delegate object is tampered with I. Syntax: Public Delegate voidEventHandler (Object sender,eventargs e); Public EventEventHandler questionevent A. Description: The sender parameter in the delegate represents the issuer of the event, and EventArgs E represents the event's Data II. EventArgs is the base class for all event arguments and does not contain data
C # language-05. Delegates and Events