我爱Aspx >> C#.Net >> c#泛型学习(二)_C#教程17 public void Tests()
18 {
19 MyClass40<int> obj = new MyClass40<int>();
20 MyClass40<int>.GenericDelegate del;
21
22 del = new MyClass40<int>.GenericDelegate(obj.SomeMethod);
23 del(3);
24
25 //委托推理
26 del = obj.SomeMethod;
27
28 }
29 }
30 #endregion
31
32 委托泛型参数#region 委托泛型参数
33 public class MyClass41<T>
34 {
35 public delegate void GenericDelegate<X>(T t, X x);
36 }
37
38 //外部委托
39 public delegate void GenericDelegate<T>(T t);
40
41 public class MyClass42
42 {
43 public void SomeMethod(int number)
44 { }
45 }
46
47 public class MyClassTest42
48 {
49 public void Test()
50 {
51 MyClass42 obj = new MyClass42();
52 GenericDelegate<int> del;
53 //del = new GenericDelegate<int>(obj.SomeMethod);
54
55 del = obj.SomeMethod;
56 del(3);
57
58 }
59 }
60
61 #endregion
62
63 委托泛型参数#region 委托泛型参数
64 public delegate void MyDelegate<T>(T t) where T : IComparable<T>;
65 #endregion
66
67 事件#region 事件
68
69 public delegate void GenericEventHandler<S, A>(S sender, A args);
70
71 public class MyPublisher
72 {
73 public event GenericEventHandler<MyPublisher, EventArgs> MyEvent;
Ҷƪл˵?
C# 3.0新特性初步研究 Part1:使用..[04-28]
C# 3.0新特性初步研究 Part2:使用..[04-28]
C# 3.0新特性初步研究 Part3:使用..[04-28]
C# 3.0新特性初步研究 Part4:使用..[04-28]
C# 3.0新特性初步研究 Part5:匿名..[04-28]
C# 3.0新特性初步研究 Part6:使用..[04-28]
C# 4.0语言将出现重大改变,带来..[04-28]
Word文档中快速插入分隔线的技巧..[04-28]
C# 2.0 套接字编程实例初探_C#教..[04-28]
DotNet(C#)学习-你学到什么程度..[04-28]
C# 3.0新特性初步研究 Part1:使用..[04-28]
C# 3.0新特性初步研究 Part2:使用..[04-28]
C# 3.0新特性初步研究 Part3:使用..[04-28]
C# 3.0新特性初步研究 Part4:使用..[04-28]
C# 3.0新特性初步研究 Part5:匿名..[04-28]
C# 3.0新特性初步研究 Part6:使用..[04-28]
C# 4.0语言将出现重大改变,带来..[04-28]
Word文档中快速插入分隔线的技巧..[04-28]
C# 2.0 套接字编程实例初探_C#教..[04-28]
DotNet(C#)学习-你学到什么程度..[04-28]