O'Reilly logo

Illustrated C# 2008 by Daniel Solis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 15. Delegates

What Is a Delegate?

A delegate can be thought of as an object that contains an ordered list of methods with the same signature and return type.

  • The list of methods is called the invocation list.

  • When a delegate is invoked, it calls each method in its invocation list.

Figure 15-1 represents a delegate with four methods in its invocation list.

A delegate as a list of methods

Figure 15-1. A delegate as a list of methods

A delegate with a single method is similar to a function pointer in C++. Unlike function pointers, however, delegates are object oriented and type-safe.

Methods in the Invocation List

Methods held by a delegate can be from any class or struct, as long ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required