Why are delegates good for C# coding: my explanation. Feedback please!

In my answer, a ‘EventManager’ is whatever class or GameObject signals (broadcasts) the event, e.g. OnGameOver or OnSpaceBarHit or OnFallSpeedExceedsThreshold. EventManager’s do not need to know who is interested it their messages. Another term for an EventManager is a ‘Subject’.

A ‘Subscriber’ is a class in the program that needs to be informed about a change in variable, or the occurrence of some event. Other terms for this are ‘Listener’ or ‘Observer’.


Using delegates, preferably implemented via C# events, has two clear benefits:

  • The EventManager does not need to maintain a list of every Subscriber. This saves it memory, some computation time, and reduces the risk that the software developer will forget to delete that Subscriber when the data transmission is redundant (both in and out of runtime).

  • The Subscriber doesn’t need to ask for an update on the value of the variable every single frame! They can just trust that they’ll hear about it via the EventManager’s broadcast on a strictly need-to-know basis, when they need to be updated. This has obvious computational/performance benefits.

Privacy & Terms