Chapter 10. Delegates and Events

A delegate is an abstraction of one or more function pointers. With a delegate, you can treat a function as data, which includes using a delegate as a variable or data member. Delegates allow functions to be passed as parameters, returned from a function as a value, and even stored in an array. Unlike function pointers in other languages, particularly C and C++, delegates are type-safe, object-oriented, and secure, which reduces common problems associated with using function pointers.

Delegates are derived from the System.MulticastDelegate class, which itself is derived from System.Delegate. System.MulticastDelegate is a reference type and is an interface for managing and executing delegates. An instance of a delegate ...

Get Programming Microsoft® Visual C#® 2008: The Language now with O’Reilly online learning.

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