C++_CLI Managed 與 Nativated 型態互轉




  1. CString -> System::String^






    CString strNativedMsg = _T(“Test”);
    System::String^ strManagedMsg = %System::String(strNativedMsg);










  2. System::String^ -> CString





    System::String^ strManagedMsg = “Test”;
    CString strNativedMsg = (CString) strManagedMsg ;








  3. System::String^ -> int


    System::String^ strManagedNumber = “123”;
    int nNativatedNumber = System::Convert::ToInt32(strManagedNumber );