Fast generation event

xiaoxiao2021-03-06  75

In .NET, you must first define an event, you must first define the type of event, but delegate, but sometimes we just want to achieve the role of the interface through the event, inform all event subscribers, the event, therefore, Such events do not require any parameters, if de-defined delegate looks some, then we can use the .NET to provide a delegate: System.EventHandler

Public Event EventHandler

EventName should be noted when triggering an event is that if the event is not subscribed to any method, it is directly touched that the event generates an exception of "empty reference", so:

IF

Eventname! = null)

Eventname (this, null);

转载请注明原文地址:https://www.9cbs.com/read-91013.html

New Post(0)