error C2665: 'System::Console::WriteLine' : none of the 19 overloads can convert parameter 2 from type 'int' boXPin.cpp(7): could be 'void System::Console::WriteLine(System::String __gc *,System::Object __gc *)' boxpin.cpp(7): or 'void System::Console::WriteLine(System::String __gc *,System::Object __gc * __gc[])' while trying to match the argument list '(char [9], int)'
Console::WriteLine("x is {0}",__box(x));封裝一個值的類別就是把值放到一個臨時對象(這個對象是System::Object繼續(xù)類的實例,存于垃圾收集堆)中,然后再把臨時對象的地址傳遞給方法調(diào)用。原有變量中所有的東西都被拷入臨時對象中,這個對象提供WriteLine()需要的所有功能。__box要害字意味著值類型和可治理類型都適合于基本類庫提供的所有服務(wù)。