I. Events: Allow objects to register events; allow objects to log off events, allow objects defining events to maintain a collection of registration objects, and
These objects are notified when a specific event occurs.
CLR events are built on the delegate (delegate.
2. events can only be registered or canceled by the event type. An event is actually a static function.
3. Events are inherited from sysetm. eventargs. The naming rule is that events should end with eventargs. The delegate should end with eventhandler
Tail. This is the Naming Standard.
4. The essence of an event is delegation. When defining an event, the C # compiler will generate a private field of the delegate type and an add _ + event name,
The remover _ + two public methods of the event name. One event is used for registration and the other is used for event cancellation. Both methods have a Commission
Parameters of the carrier type. They use the combine and remove methods of delegae respectively.
5. Use + = to register the event and-= to cancel the event. You can also display the registration and cancellation methods for defining events, with high efficiency and no need to add
Contains redundant events, because sometimes we only need a few events, but the compiler will automatically load all the events required for delegation, resulting in performance
Lower. Disadvantage implementation is troublesome.
Vi. event registration set: it is a hashtale method, and an indexer is used to register events. In CLR
The system. componmentmodel. eventhanhlerlist type is used as the event registration set.