using System;
public class Stack
{
int position;
object[] data = new object[10];
public void Push (object obj) { data[position++] = obj; }
public object Pop() { return data[--position]; }
}
public class HelloWorld
{
public static void Main()
{
// Stack stack = new Stack();
// stack.Push ("sausage");
// string s = (string) stack.Pop(); // Downcast, so explicit cast is needed
// Console.WriteLine (s); // sausage
// 装箱和拆箱
int i = 3;
object boxed = i;
i = 5;
i = (int)boxed; // Unbox the int;
Console.WriteLine (boxed); // 3
Console.WriteLine (i);
}
}