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
What is the difference between private and protected in c#?
Which compiler switch creates an xml file from xml comments in the files in an assembly?
What is parameter c#?
Explain how do you convert a value-type to a reference-type?
What are types of constructor?
What is an interface class? Give one example of it
What is the difference between method parameters and method arguments. Give an example?
What is difference between hashtable and dictionary in c#?
Can you inherit multiple abstract classes in c#?
Is unboxing an implicit conversion?
Why we use delegates in c#?
Why delegates are required?
Is predicate a functional interface?
What do you mean by “finalize” and “finally” methods in c#?
What is the difference between struct and class c#?