0

I have a text file having these inside:

test | 11 | 12 | 13 | 14 | 0

i am making a program with a data grid and im having problems splitting the rows because of the character "|". Does anyone know a solution for this ? my code below doesn't seem to work:

             foreach( string data in strArray )
             {
                 string[] textData = System.IO.File.ReadAllLines(fName);
                 string[] storedData = strArray[0].Split("|");   

                 for(int i=1; i < textData.Length; i++)
                 {
                    dataGridView1.Rows.Add(textData[i].Split(','));
                    dataGridView1.Rows.Add();
                    dataGridView1.Rows[i].Cells[0].Value = data;
                     j++;
                 }                                  
             } 

im getting the error "Cannot convert from 'string' to 'char[]'

Thanks for the help.

4

1 回答 1

0

Split() 的分隔符参数必须是chars,而不是字符串:替换Split("|")Split('|').

于 2013-01-18T08:38:35.180 回答