What Are Delegates?

As briefly mentioned before, delegates are the .NET concept that enables you to represent a function as an object. Because the concept of a mathematical function doesn’t really exist in the world of .NET, this mechanism is implemented in terms of methods instead. At the lowest level of the CLR, delegates are objects that contain a reference to some method on some object.

This section looks at how you can declare delegate types, create instances of delegates, and use them. Besides this, you look at the language-level support provided by C#, such as anonymous methods and lambda expressions. While doing so, lots of examples are presented, ultimately showing off LINQ in .NET 3.0 as one of the most recent application programming ...

Get C# 4.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.