In the above conversion, there is a delegate field _colorChanged which is created by the compiler. We can see add and removekeywords which denote explicit event accessors. These are similar to the property accessors.

2nd Step:

Now, compiler takes a deep look into our Stationary class for any references that performs operations other than -= and +=. If any found, it will redirect them to its private delegate field _colorChanged (compiler created field).

3rd Step:

Finally, compiler translates the += and -= operations on the event to the event's add and remove accessors.

Note: This makes the behavior of += and -= in case of events. In any other situations, it is simply + and - followed by an assignment.

How to use an Event?

Events are mostly used in graphical user interfaces (GUI). They can have many handlers. Let's take an example program of creating events,