1

What does the event keyword do really?

msdn says it is used to declare an event in a publisher class

// Declare the event.
public event SampleEventHandler SampleEvent;

Would that mean the SampleEvent is any less of a SampleEventHandler if I don't put event in front of it?

Besides the super awesome -= and += operators what do I get out of events/eventhandlers that I wouldn't get from List<MyDelegate>? When should I use one over the other?

CrashCodes
  • 3,237
  • 12
  • 38
  • 42

1 Answers1

0

A delegate supports += and -= operations, and so does an event. Also you can call them like methods.

But the difference is that calling an event is private to the class it belongs to, whereas += and -= are public. Also you can't assign to an event using = from outside the class either.

Daniel Earwicker
  • 114,894
  • 38
  • 205
  • 284