Boxing and Unboxing

-> Boxing is the process of converting a value type to the type object or to any type implemented by this value type. When the CLR boxes a value type, it wraps the value inside a System.Object and stores it on the managed heap. Unboxing extracts the value type from the object.
-> Boxing is used to store value types in the garbage-collected heap. Boxing is an implicit conversion of a value type to the object or to any interface type implemented by this value type.
-> An unboxing operation consists of :
1) Checking the object instance to make sure that it is a boxed value of the given value type.
2) Copying the value from the instance in to the value-type variable.

Leave a Reply

Your email address will not be published. Required fields are marked *