泛型
<T>
//泛型申明<T>
class Stack<T>
{
private T[] items;
private int count;
public Stack(int size)
{
items = new T[size];
count = 0;
}
public void Push(T x)
{
items[count++] = x;
}
public T Pop()
{
return items[--count];
}
}
class Test
{
static void Main()
{
//泛型具体化<T> --> <double>
Stack<double> s = new Stack<double>(10);
s.Push(111.1);
s.Push(222.2);
Console.WriteLine(s.Pop() + s.Pop());
Console.ReadLine();
}
}