请问怎么把一个文本文件读入数组?
比如:
1,2,3
4 5 6
读入到一个二维数组里
望指教,谢谢
------解决方案--------------------StreamReader sr = new StreamReader( "a.txt ");
string s;
int[] a=new int[100];
int i=0;
s = sr.ReadLine();
string[] ch = s.Split( ', ');
for (int j = 0; j < ch.Length; ++j)
a[i++] = int.Parse(ch[j]);
s = sr.ReadLine();
ch = s.Split();
for (int j = 0; j < ch.Length; ++j)
a[i++] = int.Parse(ch[j]);
for (int j = 0; j < i; ++j)
Console.WriteLine(a[j].ToString());