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
.
精彩评论