BoxedValue Sample: Demonstrates Throwing and Catching an Instance of a Value Class
The BoxedValue sample illustrates the throwing and catching of an instance of a value class. This sample demonstrates the need for boxing a value class instance before it is thrown and catching the boxed value as an unboxed value type.
Note An unboxed value type is a pointer to the unboxed copy of the value type instance.
For more information on boxing, see __box.
Building and Running the Sample
To build and run BoxedValue using Visual Studio
- In the Visual Studio IDE, load the solution file BoxedValue.sln.
- In Solution Explorer, right-click the BoxedValue solution.
- On the shortcut menu, click Build.
- On the Debug menu, click Start.
The following output is displayed in the console window:
Caught a boxed value type:1
This sample demonstrates the following keywords:
try, catch, __box, __value