Example #1
0
  static void TestBox() {
    ArrayList c = new ArrayList();
    SomeValue x = new SomeValue();
    x.x = 1;
    // box
    c.Add(x);
    x.x = 2;
    // box
    c.Add(x);

    // unbox
    SomeValue y = (SomeValue)c[0];

    // box while calling GetType
    x.GetType();

    // not box while calling ToString. However, Base.ToString cause boxing
    x.ToString();

    // box, interface is reference type
    IComparable v = x;
  }