Event

Events are...


 * Class members similar to fields that are of the type Delegate. Events enable a class to provide notifications.
 * Event Handler methods must have the signature void X(object, EventArgs)
 * The definition of a delegate enforces the signature.


 * Events are null until they have at least one listener.
 * A way around that if wanted:


 * Introducing an event around a delegate simply allows the compiler to make sure the delegate has the correct (event handler) signature. It also allows us to instantiate the delegate without supplying any methods for it to refer to.
 * Another benefit is that an event can be included in an interface declaration, whereas a field cannot.
 * Events can only be fired by the class that constructed it, where a delegate can be fired by any class with access.
 * “We have seen that the event keyword is a modifier for a delegate declaration that allows it to be included in an interface, constraints it invocation from within the class that declares it, provides it with a pair of customizable accessors (add and remove) and forces the signature of the delegate (when used within the .NET framework).”
 * How to:
 * Event Generator
 * Define a delegate
 * Define an event using the delegate (instantiate the delegate)
 * Raise the Event
 * Listener
 * Get a reference to the Generator
 * Assign method(s) to the event

Example:

Interestingly, you can accomplish the same thing with just a delegate: