Boxing


using System;

// Boxing is an implicit conversion of a value type to a reference type or to any interface type implemented by this value type.
public class Boxing
{    
    static void Main(String[] args)
    {
        // Converts an 'int' type to 'Object' type
        Console.WriteLine("Boxing");
        int n = 10;
        Object obj;
        obj = n;
        Console.WriteLine(obj);

        Console.WriteLine("Unboxing");
        // Converts an 'Object' type to 'int' type
        int j;
        j = (int)obj;
        Console.WriteLine(j);

        Console.ReadLine();
    }
}

Output:
Boxing
10
Unboxing
10