const char* && string && String^ 类型转换

const char* && string && String^ 类型转换

 

 

const char* ---> string

  const char * cw= "kkkkkkkkkk";

 string sw = cw;

string ---> const char*

  using namespace std;

string s = "kkkkk";

const char* cc = s.data();

 

const char* ---String^

using namespace System::Runtime::InteropServices;

const char* cc = "dddddddddd";

System::String^ cmStr = gcnew System::String(cc);

const char* iconData = "sjhfksssssl";

String^ temp = String(iconData).ToString();

 

String^ ---> const char*

 using namespace System::Runtime::InteropServices;  

String^ className = "hhhh";  

const char* ts = (char*)(Marshal::StringToHGlobalAnsi(className)).ToPointer();

 

String^ ---> string

using namespace System::Runtime::InteropServices;

 String^ className = "hhhh";  

const char* ts = (char*)(Marshal::StringToHGlobalAnsi(className)).ToPointer();  

string sw = ts;

 

string ---> String^ string sw = "shkhk"; const char* cw = sw.data(); String^ temp = String(cw).ToString();

posted @ 2014-04-10 16:11  周文  阅读(518)  评论(0编辑  收藏  举报