C#,CLI字符串转换

std::string SystemStringToStdString( System::String^ sData )
{
    int q=(int)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(sData);
    char* p=(char*)q;
    return std::string(p);
}

System::String^ stdStringtoSystemString(std::string sData)
{
    System::String^ sResult = System::Runtime::InteropServices::Marshal::PtrToStringAnsi(System::IntPtr((void*)sData.c_str()));
  
    return sResult;
}

 

posted @ 2014-09-18 13:38  rain_2012_qf  阅读(317)  评论(0编辑  收藏  举报