using System;
class BoxUboxTest {
static void Main(string[] args) {
int m = 10;
object a = m; // boxing
try {
Console.WriteLine("Value of m is:" + a);
// unbox
object n = 20;
int b = (int) n;
Console.WriteLine("Value of n is:" + b);
System.Console.WriteLine("Unboxing OK.");
Console.ReadKey();
} catch (System.InvalidCastException e) {
System.Console.WriteLine("Error: Incorrect unboxing." + e.Message);
}
}
}This program is used for to understand Boxing and UnBoxing in c#.
