30
1
using System;
2
3
public delegate int MyDelegate();
4
public class Program
5
{
6
public static void Main()
7
{
8
MyDelegate del1 = ClassA.MethodA;
9
MyDelegate del2 = ClassB.MethodB;
10
11
MyDelegate del = del1 + del2;
12
Console.WriteLine(del());
13
}
14
}
15
16
public class ClassA
17
{
18
public static int MethodA()
19
{
20
return 100;
21
}
22
}
23
24
public class ClassB
25
{
26
public static int MethodB()
27
{
28
return 200;
29
}
30
}
Cached Result
Welcome to memory swap.
The value of X is now Susan.
The value of Y is now Tom.
The value of X is now Susan.
The value of Y is now Tom.