What is the difference between boxing/unboxing and type casting?
问题 What is the difference between boxing/unboxing and type casting? Often, the terms seem to be used interchangeably. 回答1: Boxing refers to a conversion of a non-nullable-value type into a reference type or the conversion of a value type to some interface that it implements (say int to IComparable<int> ). Further, the conversion of an underlying value type to a nullable type is also a boxing conversion. (Caveat: Most discussions of this subject will ignore the latter two types of conversions.)