我爱Aspx >> C#.Net >> c#2.0泛型学习(一) _C#教程11 m_Head.NextNode = newNode;
12 }
13
14 T Find(K key)
15 {
16 Node<K, T> current = m_Head;
17 while (current.NextNode != null)
18 {
19 if (current.Key.CompareTo(key) == 0)
20 break;
21 else
22 current = current.NextNode;
23 }
24 return current.Item;
25 }
26
27}
28
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace VS2005Demo1
6{
7 public class MyBaseClassGeneric // sealed,static
8 {
9 }
10
11 interface IMyBaseInterface
12 {
13 void A();
14 }
15
16 internal class GenericClass<T> where T : MyBaseClassGeneric,IMyBaseInterface
17 {
18
19 }
20
21 class GClass<K, T> where K : MyBaseClassGeneric,IMyBaseInterface,new() where T : K
22 {
23
24 }
25
26 class GUClass<K, T> where T : K where K : MyBaseClassGeneric,IMyBaseInterface, new()
27 {
28 GClass<K, T> obj = new GClass<K, T>();
29 }
30
31
32 不能将引用/值类型约束与基类约束一起使用,因为基类约束涉及到类#region 不能将引用/值类型约束与基类约束一起使用,因为基类约束涉及到类
33
34 //class A<T> where T : struct,class
35 //{}
36
37 #endregion
38
39 不能使用结构和默认构造函数约束,因为默认构造函数约束也涉及到类#region 不能使用结构和默认构造函数约束,因为默认构造函数约束也涉及到类
40
Ҷƪл˵?
c#泛型学习(二)_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]
c#泛型学习(二)_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]