你是指 String.Split 方法吗?假如你有一个文件用于储存通讯录数据,每一行储存一个人的数据,例如:
First Name, Last Name, Age, Phone, Email, Address
那么当你把当前行读取到一个 string 变量后,你可以这样进行分割:
string currentLine = ...;
string[] items = currentLine.Split(new string[] { ", " }, StringSplitOptions.None);
上面那行分割后的结果是:
First Name
Last Name
Age
Phone
Email
Address
string
类型中的split是将字符串按照某个字符拆分成一个字符串数组,例如有这样一个字符串str="abcd;ert;yui"
使用string[]
strs=str.split(';')则将获得一个三元素的字符串数组{abcd,ert,yui}