36
1
using System;
2
3
public class DelegateTest
4
{
5
//Declaration
6
//Creating Delegates with no parameters and no return type.
7
public delegate void FirstDelegate();
8
9
public void funtion1()
10
{
11
Console.WriteLine("I am Function 1");
12
}
13
public void funtion2()
14
{
15
Console.WriteLine("I am Function 2");
16
}
17
18
}
19
20
public class Program
21
{
22
public static void Main(string[] args)
23
{
24
DelegateTest testdelegate = new DelegateTest();
25
//Instantiation
26
DelegateTest.FirstDelegate fd1 = new DelegateTest.FirstDelegate(testdelegate.funtion1);
27
DelegateTest.FirstDelegate fd2 = new DelegateTest.FirstDelegate(testdelegate.funtion2);
28
29
30
//Invocation
31
fd1();
32
fd2();
33
34
35
}
36
}
Cached Result