Read 2D matrix from file to 2D int array in C#
问题 I have problem in reading 2D text from file and import it to an int array. Specifically, my text file looks like below: 2,3,4,5,6 5,2,3,4,5 2,4,6,7,4 2,7,8,5,6 So each cell in matrix is separated by comma and each new row starts with new line. I tried many ways to make it works but I can't! Simply, I want an int[][] or int[,] array at the end. P.S: I can read 1-D matrix simply to int[] as below: int[] array= File.ReadAllText(fileppath).Split(',').Select(t => int.Parse(t)).ToArray(); 回答1: //