Events

Learn to notify subscribers using events.

We'll cover the following

Introduction

To restrict access to the delegate that contains the methods to be invoked, we can use events. Events are essentially wrappers around delegates that hide delegate properties and instead provide only two actions:

  • Subscribers can register themselves or
  • They can remove themselves if they no longer want to be notified.

Use events

Consider the example from the previous lesson, but rewritten using an event:

Get hands-on with 1200+ tech skills courses.