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,097
  • 12
  • 36
  • 41

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
  • 111,938
  • 35
  • 201
  • 280