Mastering C# Up and Down (4-June-2024)
Mastering C# Up and Down (4-June-2024)
Unboxing
Unboxing is an explicit conversion from the type object to
a value type or from an interface type to a value type that
implements the interface.
An unboxing operation consists of:
Checking the object instance to make sure that it is a
boxed value of the given value type.
Copying the value from the instance into the value-type
variable.
int i = 123; // a value type object o = i; // boxing int j =
(int)o; // unboxing