Box int to object and unbox it back : Int Box Unbox : Data Type C# Examples


C# Examples » Data Type » Int Box Unbox »

 

Box int to object and unbox it back









    
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
        }
}
    
   
  
   



Output

Value is: 55


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Int Box Unbox