Ishu_15hu

Boxing/Unboxing C#

Dec 1st, 2020
493
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         int x = 10;
  8.         object y = x; // Boxing: Value type to reference type
  9.         Console.WriteLine(y);
  10.        
  11.         int z = (int)y; // Unboxing: Reference type to Value type
  12.         Console.WriteLine(y);
  13.     }
  14. }
RAW Paste Data