如何将char *转换为System :: string ^

时间:2010-08-06 13:01:56

标签: string c++-cli

  

可能重复:
  What is the best way to convert between char* and System::String in C++/CLI

您好, 我在使用\ clr之类的c ++项目中有一个函数:

int WINAPI dmtTest(char *pcertificate) 
{    
    String^ sCertificate;    
    sCertificate = pcertificate; // how can I assign pcertificate to sCertificate?
    ....
}

1 个答案:

答案 0 :(得分:17)

你可以这样做:

String^ sCertificate;
sCertificate = gcnew String(pcertificate);