using System.Collections;
static void Main(string[] args)
{
TestStack();
}
//------------------------------------------------------
// 堆栈(Stack)
public static void TestStack()
{
Stack st = new Stack();
st.Push('a');
st.Push('b');
st.Push('c');
st.Push('d');
Console.WriteLine("当前栈: ");
foreach (char c in st)
{
Console.Write(c + " ");
}
Console.WriteLine();
st.Push('e');
st.Push('f');
Console.WriteLine("栈顶元素: {0}",
st.Peek());
Console.WriteLine("当前栈: ");
foreach (char c in st)
{
Console.Write(c + " ");
}
Console.WriteLine();
Console.WriteLine("出栈 ");
st.Pop();
st.Pop();
st.Pop();
Console.WriteLine("当前栈: ");
foreach (char c in st)
{
Console.Write(c + " ");
}
Console.ReadLine();
}
//------------------------------------------------------