Re: The practical use of delegates
- From: "Ignacio Machin \( .NET/ C# MVP \)" <machin TA laceupsolutions.com>
- Date: Mon, 24 Sep 2007 13:15:13 -0400
Hi,
"OldCaDog" <sbass93az@xxxxxxxxxxxxxxxx> wrote in message
news:62900D3D-F598-4A8D-813F-D31820CD9804@xxxxxxxxxxxxxxxx
My question is regarding the use of delegates in C#. I see how .Net uses
delegates to wire event handlers to events. It's an object created by a
single line of code by the system and that makes perfect sense to me. I
understand that there is a lot of code underneath that the system has
created
that makes it all work, thereby making it pretty efficient for the
programmer.
Outside of the use of delegates to wire event handlers, you can create
your
own delegates to make a call to a method, which according to some, makes
delegates perfect for implementing callbacks. My question is this:
In a lot situations, I can create less code by calling that function or
method directly rather than using delegates (for static or instance
methods).
You are right, but what if you do not know the actual method you will need
to call?
A callback is an excellent example of this.
In this case you need a feature that let you dynamically select which method
to call. This feature are the delegates.
.
- Prev by Date: Re: The practical use of delegates
- Next by Date: Re: Return collection interfaces or collection objects???
- Previous by thread: Re: The practical use of delegates
- Next by thread: Re: The practical use of delegates
- Index(es):
Relevant Pages
|