我想在string不使用的情况下将a 分成一个单词数组string.Split.我已经尝试过这段代码了,但它无法将结果分配给数组
string str = "Hello, how are you?";
string tmp = "";
int word_counter = 0;
for (int i = 0; i < str.Length; i++)
{
if (str[i] == ' ')
{
word_counter++;
}
}
string[] words = new string[word_counter+1];
for (int i = 0; i < str.Length; i++)
{
if (str[i] != ' ')
{
tmp = tmp + str[i];
continue;
}
// here is the problem, i cant assign every tmp in the …Run Code Online (Sandbox Code Playgroud)