Delegates (Continued)

Learn about additional applications of delegates.

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 updates its state accordingly. For simplicity’s sake, our FootballMatch class only tracks the scores:

Get hands-on with 1400+ tech skills courses.