-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeligatess.cs
52 lines (50 loc) · 1.56 KB
/
deligatess.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
namespace Multicastdeligates
{
public delegate void SampleDelegate(out int Integer);
class Program
{
static void Main(string[] args)
{
/* SampleDelegate del1, del2, del3, del4;
del1 = new SampleDelegate(SampleMethodOne);
del2 = new SampleDelegate(SampleMethodTwo);
del3 = new SampleDelegate(SampleMethodThree);
//Multicast delegate point to more than one function.
del4 = del1 + del2 + del3;
del4 -= del2;
del4();*/
SampleDelegate del = new SampleDelegate(SampleMethodTwo);
del += SampleMethodOne;
//del += SampleMethodThree;
//del -= SampleMethodTwo;
int delegateOutputParameterValue = -1;
del(out delegateOutputParameterValue);
Console.WriteLine("delegateOutputParameterValue is {0}", delegateOutputParameterValue);
}
/*public static void SampleMethodOne()
{
Console.WriteLine("SampleMethodOne Invoked");
}
public static void SampleMethodTwo()
{
Console.WriteLine("SampleMethodTwo Invoked");
}
public static int SampleMethodTwo()
{
return 2;
}
public static int SampleMethodOne()
{
return 1;
}*/
public static void SampleMethodTwo(out int Number)
{
Number = 2;
}
public static void SampleMethodOne(out int Number)
{
Number = 1;
}
}
}