13. Delegates and Events

PREVIOUS CHAPTERS DISCUSSED extensively how to create classes using many of the built-in C# language facilities surrounding classes. The objects instantiated from classes encapsulate data and operations on data. As you create more and more classes, you see common patterns in the relationships between these classes. The previous chapter covered one such set of patterns.

Another pattern is to pass one or more methods to a receiver for invocation. This last pattern comprises the building blocks of larger patterns called publish-subscribe patterns. The use of methods as a data type and their support for publish-subscribe patterns is the focus of this chapter.

Virtually everything described within this chapter is possible ...

Get Essential C# 2.0 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.