问题
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