• λ我爱Aspx >> C#.Net >> c#2.0泛型学习(一) _C#教程
  • c#2.0泛型学习(一) _C#教程

  • :aspxer  Դ:internet  :2007-4-28 20:58:05  ؼ: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#教程
    һƪc#泛型学习(二)_C#教程