Boxing.cpp
上传用户:sz0451
上传日期:2022-07-29
资源大小:256k
文件大小:1k
- // This is the main project file for VC++ application project
- // generated using an Application Wizard.
- #include "stdafx.h"
- #using <mscorlib.dll>
- using namespace System;
- // This is the entry point for this application
- #ifdef _UNICODE
- int wmain(void)
- #else
- int main(void)
- #endif
- {
- Console::WriteLine(S"Boxing Example");
- // Create an int
- int foo = 12;
- // Box it
- Object* pFoo = __box(foo);
- // Use the boxed object
- Console::WriteLine("Value of foo is {0}", pFoo);
- // Unbox the value
- int fooTwo = *dynamic_cast<__box int*>(pFoo);
- Console::WriteLine("fooTwo is {0}", __box(fooTwo));
- return 0;
- }