A simple boxing/unboxing example : Boxing Unboxing : Data Types C# Source Code


Custom Search

C# Source Code » Data Types » Boxing Unboxing »

 

A simple boxing/unboxing example









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/


// A simple boxing/unboxing example. 
using System; 
 
public class BoxingDemo { 
  public static void Main() { 
    int x; 
    object obj; 
 
    x = 10; 
    obj = x; // box x into an object 
 
    int y = (int)obj; // unbox obj into an int 
    Console.WriteLine(y); 
  } 
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Data Types
» Boxing Unboxing