events Make Working with delegates Easier

Particularly for UI code, events are the primary means of notification. Button clicks, mouse over, list expansion, and so on all use events to notify the application of the occurrence of an event. events are based on delegates, so many of the same principles apply to events that apply to delegates. Events are so similar to delegates that the benefits of events are not readily apparent. Maybe a couple of examples will help you appreciate an event.

Beginning events

The first sample shows how an event can be used to notify an application that something has changed. For this sample, the change is incrementing and decrementing an integer. After each modification, the registered events are called. A portion ...

Get .NET Common Language Runtime Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.