System::String^ to std::string
void MarshalString ( System::String^ s, std::string& os )
{
using namespace System::Runtime::InteropServices;
const char* chars = (const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer();
os = chars;
Marshal::FreeHGlobal(IntPtr((void*)chars));
}
std::string to System::String^
string s="aaaaaaaaaaa";
String^ str=gcnew String(s.c_str());
String^ str=gcnew String(s.c_str());
char * to System::String^
char *ch="this is char pointer";
String^ str=gcnew String(ch);// 或 :System::Runtime::InteropServices::Marshal::PtrToStringAnsi((IntPtr)ch);
std::string to char *
string str="hello";
char * ch;
ch=str;