Boxing occurs when passing values : Boxing Unboxing « Data Type « C# / CSharp Tutorial






using System; 
 
class MainClass { 
  public static void Main() { 
    int x; 
    
    x = 10; 
    Console.WriteLine("Here is x: " + x); 
 
    // x is automatically boxed when passed to sqr() 
    x = sqr(x); 
    Console.WriteLine("Here is x squared: " + x); 
  } 
 
  static int sqr(object o) { 
    return (int)o * (int)o; 
  } 
}
Here is x: 10
Here is x squared: 100








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