Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / October 2006

Tip: Looking for answers? Try searching our database.

Delegates ????

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ginny - 02 Oct 2006 10:07 GMT
Hi,
Delegates allow you to specify at run time the method to be invoked.??

What does the above line mean?? Everytime, I have seen a .NET code related
to delegates, we specify the method to be invoked, ie., while coiding we
have to specify the method. Then what is meant by runtime here ??

Can anyone explain the true benefits of using a delegate???

Signature

Regards
Ginny

Cowboy (Gregory A. Beamer) - 02 Oct 2006 13:43 GMT
There are a couple of ways of changing the delegate at runtime. First, is
through a configuration file where you add handlers based on the
configuration. This may not seem runtime, as you have probably tested prior
to production compile, but it is technically runtime binding. You can also
reflect and add the delegate.

Benefits of a delegate? The primary one is to be able to raise events in one
class and handle them in another class. Yes, this is an oversimplification,
but i is an easy concept to grasp.

Signature

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************

> Hi,
> Delegates allow you to specify at run time the method to be invoked.??
[quoted text clipped - 4 lines]
>
> Can anyone explain the true benefits of using a delegate???
Neil B - 02 Oct 2006 14:21 GMT
> Hi,
> Delegates allow you to specify at run time the method to be invoked.??
[quoted text clipped - 4 lines]
>
> Can anyone explain the true benefits of using a delegate???

I understand delegates (and use them) as the equivalent of old C
function pointer prototypes. If in an old C program you wanted to use
function pointers to call routines which were specified at run-time, you
would need to carefully define the prototype of the function to be
called. So it is true of delegates: if you want to call an Event, you
have to know what arguments to pass to the event, which in turn are
defined by the Event delegate.

Hope this helps.

Neil B
Jon Skeet [C# MVP] - 02 Oct 2006 18:08 GMT
> Delegates allow you to specify at run time the method to be invoked.??
>
[quoted text clipped - 3 lines]
>
> Can anyone explain the true benefits of using a delegate???

See http://www.pobox.com/~skeet/csharp/events.html

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.