Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| class TestUnboxing | |
| { | |
| static void Main() | |
| { | |
| int i = 123; | |
| object o = i; // implicit boxing | |
| try | |
| { | |
| int j = (short)o; // attempt to unbox | |
| System.Console.WriteLine("Unboxing OK."); | |
| } | |
| catch (System.InvalidCastException e) | |
| { | |
| System.Console.WriteLine("{0} Error: Incorrect unboxing.", e.Message); | |
| } | |
| } | |
| } |