Summary

   


This chapter discussed delegates and events and their importance for implementing event driven programs in C#. The important points mentioned in this chapter are as follows.

A delegate is a subclass of System.Delegate. It specifies the return and parameter types for the methods it can encapsulate. When a delegate is called, it delegates this call to the method implementation of the method is encapsulates.

Delegates let us postpone method implementation decisions until runtime. For example, arrays of delegates let us decide on sequences of operations during runtime, and method implementations can be passed around as arguments to methods.

A multicast delegate can encapsulate more than one method. Any delegate with the return type void is automatically a multicast delegate. Multicast delegates are particularly useful for event-driven programs.

An event signals that something noteworthy happened in the program. In C#, an event is implemented with a multicast delegate. An event-driven program consists of publisher objects firing events and subscriber objects containing event handlers that are invoked by these notifications.


   


C# Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 286
Authors: Stephen Prata

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net