Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what are delegates? How you used then in your project?

Answer Posted / prashanth

Delegate means function pointer.
There are two types of delegate
1-simple delegate
2-multicast delegate.

for simple ex:

private void Page_Load(object sender, System.EventArgs e)
{
Label2.Text= DoAction(new Action(Add)).ToString();
Response.Write ("<BR>");
Label3.Text= DoAction(new Action(Sub)).ToString();
//
// // Put user code to initialize the page here
}

static int DoAction(Action action)
{
return action(5,2);
}
public int Add(int n,int m)
{
return n+m;
}
public int Sub(int n,int m)
{
return n-m;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the properties of a string class?

1098


Explain what is the smallest unit of execution in .net?

986


What is the best dependency injection c#?

930


What will be the output of the following code?

970


How do I automate my desktop application?

1057


What is action in c# 3.5?

1020


What is the implicit name of the parameter that gets passed into the set method/property of a class?

971


Does c# support properties of array types?

973


How many constructors can a class have c#?

959


What is class and object c#?

952


How do you specify a custom attribute for the entire assembly?

1033


Explain the difference between abstract class and interface.

1222


Can abstract class have constructor c#?

922


What is the difference between returning iqueryable vs ienumerable?

1036


What are the namespace level elements?

1060