Delegates

Delegates are the ultimate function pointer. Developers familiar with C and C++ are very familiar with function pointers and their lack of instance-based knowledge. A delegate can be thought of as a call back mechanism, essentially saying, “Please invoke this method for me when the time is right.”

Consider the following scenario: Your department has just hired a new employee. Human Resources needs to be notified when a new employee is hired so they can put them to sleep with endless paper work and boring drivel about company policies and practices. This type of interaction is a perfect example of a delegate. Basically, Human Resources is requesting a notification when a new employee is hired and provides a method to be invoked. Listing ...

Get C# and the .NET Framework: The C++ Perspective 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.