using System; class MainClass { public static void Main() { int v = 55; object o = v; // box v into o Console.WriteLine("Value is: {0}", o); int v2 = (int) o; // unbox back to an int } }
Value is: 55
2.6.int Box Unbox | ||||
2.6.1. | Integer Autobox | |||
2.6.2. | Box int to object and unbox it back | |||
2.6.3. | implicit boxing from i to object |