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