我爱Aspx >> C#.Net >> c#2.0泛型学习(一) _C#教程20 throw new StackOverflowException();
21
22 m_Items[m_StackPointer] = item;
23 m_StackPointer++;
24 }
25 public T Pop()
26 {
27 m_StackPointer--;
28 if (m_StackPointer >= 0)
29 {
30 return m_Items[m_StackPointer];
31 }
32 else
33 {
34 m_StackPointer = 0;
35 //throw new InvalidOperationException("Cannot pop an empty stack");
36 return default(T);
37 }
38 }
39}
40
41public class Stack1<T> : Stack<T>
42{
43
44}
45
下为PDF文档,我感觉挺好的,很简单,我听的懂就是好的
/Clingingboy/one.pdf
多个泛型
1class Node<K, T>
2{
3 public K Key;
4 public T Item;
5 public Node<K, T> NextNode;
6 public Node()
7 {
8 Key = default(K);
9 Item = default(T);
10 NextNode = null;
11 }
12 public Node(K key, T item, Node<K, T> nextNode)
13 {
14 Key = key;
15 Item = item;
16 NextNode = nextNode;
17 }
18}
泛型别名
1using list = LinkedList<int, string>;
泛型约束
1public class LinkedList<K, T> where K : IComparable
2{
3 Node<K, T> m_Head;
4 public LinkedList()
5 {
6 m_Head = new Node<K, T>();
7 }
8 public void AddHead(K key, T item)
9 {
10 Node<K, T> newNode = new Node<K, T>(key, item, m_Head.NextNode);
Ҷƪл˵?
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]