What is delegates

Nandkishor
Asked Nov 17, 2009
as for as my concerend delegates is the reference type . so on the run time we can cange its reference .

for ex..
a cofy machine have like a delegates u choose cofy than u will get a cup of cofy ..
but if u will select a tea than u will get tea..

so its means it is chainging it reference at run time
Nandkishor
Answered Nov 17, 2009
no sorry...............
Delegate is reference type varible that is used to hold the address of one or more method at the same time.
There are two types of delegate.
1>SingleCast delegate that contains address of one method
2>MultipleCast Delegate that holds multiple reference at the same type.

if You want to see the coding in C# then u can visit this url

http://www.shadab-programminghelp.blogspot.com/
shadab
Answered Dec 19, 2009
Delegates are very similar to 'pointers to functions' in C and C++

First we create a delegate, then we can assign any function that has a similar prototype of the one which we have specified with the delegate.

Declaration:

public delegate int Dlg(int x, int y); //where Dlg is the name of Delegate


http://www.cegonsoft.com/jobassistanceprogram.php


Create Object:
when we need to create a 'Delegate object' (i.e. a pointer to a function which has a specified prototype)

Dlg d1=new Dlg(function_name); //if the class is in some other class use 'class_name.function_name'

function_name->has to be the name of a function which receives two integers as arguments and return an integer

Invoking function:

int res=d1(20, 20);



http://www.aboutcegonsoft.com/ - Cegonsoft

suryaprasath
Answered Jul 13, 2011
Edited Jul 13, 2011

TIP: If it's not your answer to this question, please click "Leave a Comment" button under the question to communicate with the question owner.

Categories