我正在用C++/CLI开发一个应用程序,并且在非托管代码中有一个csv文件编写库,我想从托管部分使用它.所以我的函数看起来像这样:
bool CSVWriter::Write(const char* stringToWrite);
Run Code Online (Sandbox Code Playgroud)
...但我真的很难将我闪亮的System :: String ^转换为兼容的东西.基本上我希望通过做类似的事情来打电话:
if( m_myWriter->Write(String::Format("{0}",someValueIWantToSave)) )
{
// report success
}
Run Code Online (Sandbox Code Playgroud) 如何将'String ^'转换为'const char*'?
String^ cr = ("netsh wlan set hostednetwork mode=allow ssid=" + this->txtSSID->Text + " key=" + this->txtPASS->Text);
system(cr);
Run Code Online (Sandbox Code Playgroud)
错误:
1 IntelliSense: argument of type "System::String ^" is incompatible with parameter of type "const char *"
Run Code Online (Sandbox Code Playgroud)