Chapter 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 to do using programming concepts that I discussed earlier in the book. However, the delegate and event constructs provide a simplified means of implementing callback and listener patterns, saving developers from reimplementing the same pattern multiple times throughout their code. By using these constructs, code becomes easier to read and write.

Essential C# 2.0
Essential C# 2.0
ISBN: 0321150775
EAN: 2147483647
Year: 2007
Pages: 185 © 2008-2017.
If you may any questions please contact us: