static void TestValueTypeAndReferenceType() { SomeValue x1 = new SomeValue(); SomeRef y1 = new SomeRef(); x1.x = 5; y1.x = 5; SomeValue x2 = x1; SomeRef y2 = y1; }
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; }