Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

i been working in dotnet (asp.net with c#) for last 4 months.

But still i dont understand what a 'Delegate' mean.

Could some one help me out in defining its importance as well where to use it?

  • *Experts*
Posted

[mshelp]ms-help://MS.VSCC/MS.MSDNVS/csref/html/vcrefTheDelegateType.htm[/mshelp]

 

A delegate is used if you want to pass a specific function as a

parameter to another function, and then that delegate will be

used within the function called.

 

In other words, you can create many functions with the

same signature that do different things (string parsing, for example),

and then pass one of those to ANOTHER function so that it is

called.

 

Sorry if that's confusing... look at the examples given in the MS

help for a better idea.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

Hopefully I won't confuse anyone further...

 

I think of delegates like class interfaces, except they're more generic. You declare an interface, then create an object of that interface and point it to a function that shares the same interface (same return type and paremeters). Then, through that interface, you can use the function(s) in which it points to.

 

The link Bucky gave you has excellent examples. Delegates in C# are mostly used to determine which events point to which functions.

Gamer extraordinaire. Programmer wannabe.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...