Abstract
Delegates provide a built-in, language-supported mechanism for defining and executing callbacks. Their flexibility allows you to define the exact signature of the callback, and that information becomes part of the delegate type itself. Anonymous functions are forms of delegates that allow you to shortcut some of the delegate syntax that, in many cases, is overkill and tedious.1 Building on top of delegates is the support for events in C# and the .NET platform. Events provide a uniform pattern for hooking up callback implementations—and possibly multiple instances thereof—to the code that triggers the callback.
Even better than anonymous functions are lambda expressions, which deserve an entire chapter and are covered in Chapter 15.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights and permissions
Copyright information
© 2007 Weldon W. Nash, III
About this chapter
Cite this chapter
(2007). Delegates, Anonymous Functions, and Events. In: Accelerated C# 2008. Apress. https://doi.org/10.1007/978-1-4302-0338-4_10
Download citation
DOI: https://doi.org/10.1007/978-1-4302-0338-4_10
Publisher Name: Apress
Print ISBN: 978-1-59059-873-3
Online ISBN: 978-1-4302-0338-4
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)