开发者

keyword event in c# [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Why do we need the “event” keyword while defining events ?

in the MSDN exemple : http://msdn.microsoft.com/开发者_如何学运维fr-fr/library/w369ty8x(v=VS.80).aspx

If i delete the event keyword from the publisher class, my project work. so wy we add the key word event.

thanks


Because of encapsulation. If keyword 'event' will be removed then you will be able to invoke 'event' and even change it's subscriptions from external classes which do not own the event. See Jon's answer here. With event keyword you're sharing an event, without it you're giving an access to delegate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜