blob: 466c04f4908b9cec5245f51bdf3fb53758884e00 (
plain)
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
|
// Generic delegates.
using System;
delegate void Test<T> (T t);
class Foo<T>
{
public event Test<T> MyEvent;
public void Hello (T t)
{
if (MyEvent != null)
MyEvent (t);
}
}
class X
{
static void do_hello (string hello)
{
Console.WriteLine ("Hello: {0}", hello);
}
public static void Main ()
{
Foo<string> foo = new Foo<string> ();
foo.MyEvent += new Test<string> (do_hello);
foo.Hello ("Boston");
}
}
|