What in C # delegate is? The event is not a delegate? The relationship between events and delegates.

The delegate can be a method of substituting another method as a parameter.

Commissioned point can be understood as a pointer to the function.

Delegates and events are not comparable, because the commission is the type of event is the object , you said the following is the object (event realized on commission) and commissioned (standard difference event manner) event. Internal event is entrusted to achieve . Because for the event in terms of external only "+ = register themselves, cancellation of own - =", the outside world can not be written off other registrants, the outside world can not take the initiative to trigger events, so if you use Delegate  can not hold the above control, therefore this event was born syntax. Events are used to delegate instance castrated, the analogy with a custom class castration List. Events can only add, remove yourself, can not be assigned. Events can only + =, - =, not =  . Supplementary answer points: the internal event is a private commission and add, remove two methods

 

 

Reproduced in: https: //www.cnblogs.com/boke1/p/11056643.html

Guess you like

Origin blog.csdn.net/weixin_33968104/article/details/93082049