我想将一个字符串放入数组中,假设我有一个像 string a = "dog cat horse mouse"
这样的字符串,所以我想将这个字符串放入一个数组中,就像一个单独的工作一样出现在字符串中。
string array [0]=dog
string array [1]=cat
string array [2]=horse
string array [3]=mouse
或者像这样
string array= {"dog", "Cat", "mouse", "horse"};
我想在数组中像这样,所以:)
最佳答案
您可以使用 Split方法:
string a = "dog cat horse mouse";
string[] array = a.Split(' ');
关于c# - 串成数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5005726/