我想从文本框中取一个字符串(txtFrom)并保存第一个单词并保存剩下的部分.(剩下的就是第一个空间的一切)
示例string ="Bob jones去了商店"
array [0]会给"Bob"
数组[1]给"琼斯去商店"
我知道有string[] array = txtFrom.Split(' ');,但这给了我一个6个单词的数组.
man*_*lds 37
String.Split(Char[], Int32)像这样使用重载:
string[] array = txtFrom.Text.Split(new char[]{' '},2);
Run Code Online (Sandbox Code Playgroud)
http://msdn.microsoft.com/en-us/library/c1bs0eda.aspx