Skip to Main Content
C# 10.0 All-in-One For Dummies
book

C# 10.0 All-in-One For Dummies

by John Paul Mueller
March 2022
Intermediate to advanced content levelIntermediate to advanced
864 pages
19h 46m
English
For Dummies
Content preview from C# 10.0 All-in-One For Dummies

Chapter 8

Delegating Those Important Events

IN THIS CHAPTER

Bullet Solving callback problems with delegates

Bullet Using delegates to customize a method

Bullet Using anonymous methods

Bullet Creating events in C#

This chapter looks into a corner of C# that has been around since the birth of the language. The ability to create a callback, a method used to handle events, is essential for C# applications of all sorts. In fact, the callback appears in applications of every kind today. Even web-based applications must have some sort of callback mechanism to allow them to work properly.

The alternative is to hold up the application while you wait for something to happen, which means that the application won’t respond to anything but the anticipated input. That’s how the console applications used in examples to this point work. The Console.Read() call essentially stops the application until the user does something. A console application can work in this manner, but when a user could click any button on a form, you must have something better — a callback mechanism. In C#, you implement a callback by using a delegate, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 9781119839071Purchase Link