Chapter 10. Delegates and Events

Delegates are the foundation of events. If you have used scripting languages before, you should be familiar with the concept of events. A user may interact with a Web page and click a button. The action of clicking generates an OnClick event. The JavaScript in the page may then do something as a result of the click action.

Delegates are classes that store functions. A developer first defines a delegate class. The definition of the delegate—as you will see in the sections in this chapter—contains a prototype for the type of functions that the delegate can store. A developer then declares a variable of the delegate type and assigns a function to it. The function could be an instance function in an object, or a static ...

Get C# Web Development with ASP.NET: Visual QuickStart Guide 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.