Change the value after boxing : Boxing Unboxing « Data Type « C# / CSharp Tutorial






using System;

class MainClass
{
   static void Main()
   {
      int i = 10;           
      object oi = i;        
      
      Console.WriteLine("i: {0}, io: {1}", i, oi);
      
      i  = 12;
      
      Console.WriteLine("i: {0}, io: {1}", i, oi);
      
      oi = 15;
      Console.WriteLine("i: {0}, io: {1}", i, oi);
   }
}
i: 10, io: 10
i: 12, io: 10
i: 12, io: 15








2.53.Boxing Unboxing
2.53.1.A boxing/unboxing example.
2.53.2.Boxing occurs when passing values
2.53.3.Illustrate automatic boxing during function call
2.53.4.Boxing makes it possible to call methods on a value!
2.53.5.Change the value after boxing