What is a delegate?

Answer Posted / sadab alam

Delegate is refrence type varible that holds the refrence
to a method.
There are two type of delegte
1.Sigle cast delegate
2.Multi cast delegate
if delgate variable contains refrence of one method then it
is called sinlecast delegate
and if contains refrence of more than one method then it is
called multicast refrence.

using System;
public delegate void mydel();
class del
{
public static void method1()
{
Console.WriteLine("first method");
}
public static void method2()
{
Console.WriteLine("Second method");

}
public static void Main()
{
mydel d=new mydel(method1);
d+=new mydel(method2);
d();
}
}

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

List down the commonly used types of exceptions in .net

568


What is uint16?

585


Why do we need structs in c#?

525


What is difference between internal and protected internal in c#?

551


What is difference between variable and property in c#?

511






What do you mean by string objects are immutable?

595


What is interface c#?

540


Define delegate?

621


What is the difference between add and addrange in c#?

602


How do destructors and garbage collection work in c#?

602


What does the initial catalog parameter define in the connection string?

571


Explain About sn.exe

584


How to exclude a property from xml serialization?

646


List down the differences between public, static and void keywords?

543


What is type class in c#?

572