C++ Using System::String::Split

老子叫甜甜 提交于 2021-02-10 07:20:31

问题


I am trying to split a System::String at ":" using System::String::Split in my C++ code. The string to be split is called "responseString". It is a System::String. I have:

 char id[] = { ':' };
 return responseString->Split(id);

However, it errors at the "->" saying that no instance of the overloaded function matches the argument list. I checked the MSDN documentation, and see no information on doing this in C++.

I also tried the following, with the same results:

 System::Char id[] = { ':' };
 return responseString->Split(id);

In the documentation it shows the following example, but I do not know what to do with that:

array<String^>^ Split(
... array<wchar_t>^ separator
)

Any help would be appreciated!


回答1:


Symbol delimiter can be either of type wchar_t, either String ^, as well as their array. Here's a quick example:

String ^str="String:need:split;this";
array<wchar_t> ^id = { ':' ,';'};
array<String^> ^StringArray =str->Split(':');
array<String^> ^StringArray2 =str->Split(id);
for each(String^ temp in StringArray)
    Console::WriteLine(temp);
Console::WriteLine();
for each(String^ temp in StringArray2)
    Console::WriteLine(temp);


来源:https://stackoverflow.com/questions/29063239/c-using-systemstringsplit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!