这按预期工作:
byte b = 7; var i = (int)b;
虽然这引发了InvalidCastException:
InvalidCastException
byte b = 7; object o = b; var i = (int)o;
object当基础类型仍然存在时,为什么转换会失败byte?
object
byte
.net c# casting
.net ×1
c# ×1
casting ×1