Caffeinated Coder
Book an appointment
Lesson 16 · Working with data

Events

An event lets an object announce that something happened, without knowing who is listening. Follow an Oven that declares public event Action? Done: two handler methods subscribe with +=, Bake raises the event with Done?.Invoke() and every handler runs in order, one handler leaves with -=, and the compiler stops outside code from raising the event itself. The program prints Beep!, Flash!, Flash!.

12 min10 steps5 questionsIntermediate
Fig 16 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.