110,566
社区成员
发帖
与我相关
我的任务
分享
using System.IO;
int[,] int_array = new int[4, 4];
StreamReader sr = new StreamReader(@"C:\123.txt");//txt文件存在路径
string line = sr.ReadLine();
int j = 0;
while (line != null)
{
string[] str = line.Split(new char[] { ',' });
for (byte i = 0; (i < 4) && (i < str.Length); i++)
{
int_array[j, i] = int.Parse(str[i].Trim());
}
j++;
line = sr.ReadLine();
}
//经过测试没问题
//文本格式:
//1,2,3,4
//11,2,32,31
//3,4,5,7
//54,21,22,11