Home > Net >  C # read TXT error
C # read TXT error

Time:11-22

Private void button1_Click (object sender, EventArgs e)
{
StreamReader rd=File. OpenText (" D: \ \ test \ \ test4 TXT ");
String s=rd. ReadLine ();
String [] ss=s.S plit (");

Int row=int. Parse (ss [0]);//the number of rows
Int col=int. Parse (ss [1]);//the number of data in each row

Double [and] p1=new double [row, col];//array

for (int i=0; I & lt; The row. I++)//read the data and give array
{
The string line=rd. ReadLine ();
String [] data=https://bbs.csdn.net/topics/line.Split (', ');
For (int j=0; J & lt; Col. J++)
{
P1 [I, j]=double. Parse (data [j]);
}
}

}

TXT format is:
8 and 9 0
0 67 84
33 66 43

Always prompt reads the data format is wrong, somehow, for help bosses,
  •  Tags:  
  • C#
  • Related