现有字符串string allid,该字符串内存储的数据形式为“a1,b12,123,dar……”,即每小段字符串之间用逗号隔开。
现在我想遍历allid这个字符串,检测每一位。如果不是逗号,就把这个字符存入字符串outbyte中,如果检测到逗号时,就则把outbyte输出,并将其outbyte清空。
即遍历allid这个字符串,并把其中包含的每小段字符串分别输出出来。
代码该怎么写?
我想把每一小段字符依次在定义好的datagirdview里的第一列,直接用split分割后输出的结果不太对:
tidarray = allid.Split(',');
if (tidarray!=null)
{
for (int i = 0; i < tidarray.Length; i++)
{
DataGridViewRow gridRow = this.dataGridView1.Rows[dataGridView1.Rows.Add()];
gridRow.Cells[0].Value = tidarray;
Console.WriteLine(tidarray[i]);
}
}
没有显示每一小段字符串而是System.String[],想请问是怎么回事?