15. Delegates

Delegates enable scenarios that other languages—such as C++, Pascal, and Modula—have addressed with function pointers. Unlike C++ function pointers, however, delegates are fully object oriented. Also, unlike C++ pointers to member functions, delegates encapsulate both an object instance and a method.

Bill Wagner

I experience a strange sense of amazement upon reading this small chapter in the language specification. Delegates have been part of C# since the 1.0 release. At that time, most of the C# community (including me) saw delegates as a little extra ceremony around events. Ten years later, I can’t imagine the C# language without delegates. They are something most of us use every day in LINQ queries, function composition, ...

Get The C# Programming Language (Covering C# 4.0), Fourth Edition 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.