C#--泛型
class Program
{
static void Main(string[] args)
{
//string words = "1,2,3";
//string[] split = words.Split(',');
//foreach (string s in split)
//{
// if (s.Trim() != "")
// Console.WriteLine(s);
//}
Stack<int> stack = new Stack<int>();
stack.Push(17);
foreach (int i in stack.Store) {
Console.WriteLine(i);
}
Console.ReadKey();
}
}
class Stack<T> {
private T[] store;
public T[] Store
{
get { return store;}
set { store = value; }
}
private int size;
public Stack() {
store = new T[10]; size = 0;
}
public void Push(T x) {
store[size++] = x;
}
public T Pop() {
return store[--size];
}
}