我有这样的字符串:
string mystring = "12353 90123B41094 A01283410294 3"
我需要将具有3或4个字符串的字符串分隔开来。
这是我的尝试:
string block = "";
Arraytext = text.ToCharArray();
for(int i = 0; i <= text.Length; i++)
{
while (Arraytext[i] !=' ') { block = block + Arraytext[i]; counter++; } // also tried Arraytext[i] != '/0'
}
while (Arraytext [counter] == ' ')counter++; //to get where the next string begins
//repeat this function until the strings has been obtained
这不起作用:
' '
和'/0'
答案 0 :(得分:4)
分隔您可以使用的空格之间的单词
string mystring = "12353 90123B41094 A01283410294 3";
string[] result = mystring.Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries);