Boxing (C++/CLI)


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The latest version of this topic can be found at Boxing (C++/CLI).

Boxing is the process of converting a value type to the type object or to any interface type that's implemented by the value type. When the common language runtime (CLR) boxes a value type, it wraps the value in a System.Object and stores it on the managed heap. Unboxing extracts the value type from the object. Boxing is implicit; unboxing is explicit.

How to: Explicitly Request BoxingDescribes how to explicitly request boxing on a variable.
How to: Use gcnew to Create Value Types and Use Implicit BoxingShows how to use gcnew to create a boxed value type that can be placed on the managed, garbage-collected heap.
How to: UnboxShows how to unbox and modify a value.
Standard Conversions and Implicit BoxingShows that a standard conversion is chosen by the compiler over a conversion that requires boxing.
.NET Programming with C++/CLI (Visual C++)The top-level article for .NET programming in the Visual C++ documentation.