Handling Events with Delegates

Objects in C# can also support events. Events were created for graphical user interfaces (GUIs) like Windows so the user can direct program execution. When something happens in a GUI—the user clicks a button, moves a scroll bar, or closes a window—an event occurs. GUI code is written to respond to events, rather than simply to execute huge monolithic code blocks without user interaction. When code responds to events, the user directs the action and the program responds.

We're going to work with events in detail when creating Windows and Web applications, because events are designed for GUI environments. However, because you can handle events in C# with delegates, we'll get an introduction to the topic here. In C#, ...

Get Microsoft® Visual C#® .NET 2003 Kick Start now with O’Reilly online learning.

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