C# 5.0 ALL-IN-ONE FOR DUMMIES by Bill Sempf Chuck Sphar & Stephen Randy Davis

C# 5.0 ALL-IN-ONE FOR DUMMIES by Bill Sempf Chuck Sphar & Stephen Randy Davis

Author:Bill Sempf, Chuck Sphar & Stephen Randy Davis
Language: eng
Format: epub
Publisher: John Wiley and Sons, Inc.
Published: 2013-01-13T16:00:00+00:00


Figure 9-1: Making progress with the Windows ProgressBar control.

Defining a Delegate

C# provides delegates for making callbacks — and a number of other tasks. Delegates are the C# way (the .NET way, really, because any .NET language can use them) for you to pass around methods as though they were data.

You’re saying, “Here, execute this method when you need it” (and then handing over the method to execute).

This chapter helps you get a handle on that concept, see its usefulness, and start using it yourself.

You may be an experienced coder who will recognize immediately that delegates are similar to C/C++ function pointers — only much, much better. But I’m assuming in this section that you aren’t and you don’t.

Think of a delegate as a vehicle for passing a callback method to a “workhorse” method that needs to call you back or needs help with that action, as in doing the same action to each element of a collection. Because the collection doesn’t know about your custom action, you need a way to provide the action for the collection to carry out. Figure 9-2 shows how the parts of this scheme fit together.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Whisky: Malt Whiskies of Scotland (Collins Little Books) by dominic roskrow(56018)
What's Done in Darkness by Kayla Perrin(26591)
The Fifty Shades Trilogy & Grey by E L James(19078)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(19057)
Shot Through the Heart by Mercy Celeste(18935)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(17110)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(16989)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(16873)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16823)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 01 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16444)
The Subtle Art of Not Giving a F*ck by Mark Manson(14352)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(14128)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(13622)
Scorched Earth by Nick Kyme(12767)
Drei Generationen auf dem Jakobsweg by Stein Pia(10964)
Suna by Ziefle Pia(10888)
Scythe by Neal Shusterman(10334)
International Relations from the Global South; Worlds of Difference; First Edition by Arlene B. Tickner & Karen Smith(9520)
Successful Proposal Strategies for Small Businesses: Using Knowledge Management ot Win Govenment, Private Sector, and International Contracts 3rd Edition by Robert Frey(9366)
The Ultimate Python Exercise Book: 700 Practical Exercises for Beginners with Quiz Questions by Copy(9309)