Csharp/CSharp Tutorial/Data Type/int Box Unbox
Box int to object and unbox it back
<source lang="csharp">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 }
}</source>
Value is: 55
Integer Autobox
<source lang="csharp">using System; class MainClass {
public static void Main() { Console.WriteLine(5.ToString()); }
}</source>
5