Chapter 10. Events and Delegates
When developers made the switch from functional programming to object-oriented programming, many things became easier. The Win32 development model relies heavily on the concepts of function pointers and callbacks. In other unmanaged languages, the use of function pointers can be fraught with errors caused by type conversions. Most developers who are familiar with pointer programming are also familiar with the fact that type conversions are always a source of pain and stress.
One of the advantages of C# is how operations related to type conversion can be protected. C# doesn't support pointers to functions, but it does enable developers to use delegates and events for the implementation of callbacks and notifications. A delegate is a mechanism of the .NET Framework that is, in a nutshell, a type-safe, managed function pointer.
This chapter explains what delegates are and how to use them in C# applications. The chapter also describes the internal structure of delegates and many of the features related to building event-based systems in C#.
WHAT YOU NEED
EVENTS AND DELEGATES AT A GLANCE