110,539
社区成员
发帖
与我相关
我的任务
分享
class Program
{
static void Main(string[] args)
{
GetNumber(@"G:\array.txt");
Console.Read();
}
private static void GetNumber(string filePath)
{
int row = 2;
int column = 2;
int[,] intArray = new int[row, column];
try
{
using (StreamReader sr = new StreamReader(filePath))
{
while (!sr.EndOfStream)
{
string str = sr.ReadLine();
string[] strArray = str.Split(',');
intArray[int.Parse(strArray[0]), int.Parse(strArray[1])] = int.Parse(strArray[2]);
}
}
}
catch(Exception e)
{
string msg = e.Message;
}
for (int i = 0; i < column; i++)
{
for (int j = 0; j < row; j++)
{
Console.Write(intArray[i,j].ToString() + " ");
}
Console.Write("\n");
}
}
}