Delegates (Continued)
Explore how to use delegates in C# to create flexible and maintainable event notifications. Understand why delegates improve code design by enabling subscriber registration without modifying core classes like the FootballMatch example. Learn about controlling delegate access and why events provide better encapsulation for event handling.
We'll cover the following...
Introduction
Throughout this section, we’ve seen various ways to create and instantiate delegates. We primarily focused on syntax while overlooking the practical uses of delegates. Why do we need them? After all, we can simply create methods and call them directly instead of declaring a delegate type and creating regular and anonymous methods that suit it.
Suppose we have a class that represents a football game. It tracks the events of the game and ...