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...

coding for delegates?

Answer Posted / dotnet user

using System;
// Declare delegate -- defines required signature:
delegate void SampleDelegate(string message);

class MainClass
{
// Regular method that matches signature:
static void SampleDelegateMethod(string message)
{
Console.WriteLine(message);
}

static void Main()
{
// Instantiate delegate with named method:
SampleDelegate d1 = SampleDelegateMethod;
// Instantiate delegate with anonymous method:
SampleDelegate d2 = delegate(string message)
{
Console.WriteLine(message);
};

// Invoke delegate d1:
d1("Hello");
// Invoke delegate d2:
d2(" World");
}
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a void c#?

918


How to Show Message box in Metro Style App?

1027


What is a Command Object in C#?

1034


What is disconnected data architecture in c#?

1029


Why to use lock statement in c#?

937


Explain when should you call the garbage collector in .net?

916


What is the advantage of dependency injection?

997


What is the difference between integer and double?

923


Is it possible to force garbage collector to run?

905


What is the use of thread join in c#?

920


What is msil in c#?

962


Is arraylist type safe in c#?

992


What is action in c# 3.5?

974


How do you prevent a class from being inherited in c#?

849


Why are local variables stored in stack?

1037