What are Events?
Events are higher level of encapsulation over delegates. Events use delegates internally. Delegates are naked and when passed to any other code, the client code can invoke the delegate. Event provides a publisher / subscriber mechanism model.
So subscribers subscribe to the event and publisher then push messages to all the subscribers. Below is a simple code snippet for the same: -
Create a delegate and declare the event for the same.
public delegate void CallEveryone();
public event CallEveryone MyEvent;
Raise the event.
Attached client methods to the event are fired / notified.
obj.MyEvent += Function1;
Do events have return type?No, events do not have return type.
Can events have access modifiers?Yes.
Can we have shared events?Yes, you can have shared events, do note only shared methods can raise shared events.
See following video on Delegate and Events: -
Click and see here for more
step by step learning .NET.