arun_mrk Posted April 4, 2003 Posted April 4, 2003 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? Quote
*Experts* Bucky Posted April 4, 2003 *Experts* Posted April 4, 2003 [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. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
wyrd Posted April 4, 2003 Posted April 4, 2003 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. Quote Gamer extraordinaire. Programmer wannabe.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.