Int32 i = 10;
Object obj = new Object();
try
{
obj = i;
Console.Write("装箱成功\n");
// Console.Write()
}
catch(Exception ex)
{
Console.Write("装箱失败");
Console.Write(ex.ToString());
return;
}
try
{
Int64 j = (Int64)obj;//这里会出现错误
Console.Write("拆箱成功");
}
catch(Exception ex)
{
Console.Write("装箱失败");
Console.Write(ex.ToString());
}
Console.Read();
如要修改:Int64 j = (Int64)(Int32)obj