Boxing and Unboxing
It's
better to say that boxing (and unboxing) is a specialised form of
casting or type-casting. In .NET, every class derives from the "object"
class. Since the "object" class is the base class of all objects, any
object can be cast to the type "object" and then reconverted to the
specific type. The conversion from specific type to "object" is called
boxing and the reverse is called unboxing. Unlike traditional casting,
any object or datatype can be boxed and unboxed. In traditional
casting, there are certain limitations. For example, string type cannot
be cast into, say, int type. But any object or variable can
be cast to "object". So in simple terms, boxing is casting from
specialised type to type "object" and unboxing is the reverse.Regards,
Mitesh Mehta
Microsoft Certified Professionalmiteshvmehta@gmail.com
Friday, July 16, 2004
Boxing and Unboxing
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment