I was trying to use a List<List<int>> Code :
List<List<int>> list2D = new List<List<int>>();
List<int> NULLLIST = new List<int>();
NULLLIST.AddRange(Enumerable.Repeat(0, 6));
list2D.AddRange(Enumerable.Repeat(NULLLIST, 6));
for (int i = 1; i <= 5; i++)
for (int j = 1; j <= 5; j++)
list2D[i][j] = (5 * (i-1)) + j;
for (int i = 1; i <= 5; i++, Console.WriteLine())
for (int j = 1; j <= 5; j++)
Console.Write(list2D[i][j].ToString() + ' ');
Console.ReadLine();
I thought the output would be like this
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
but the output was
21 22 23 24 25
21 22 23 24 25
21 22 23 24 25
21 22 23 24 25
21 22 23 24 25
I don't know what is wrong and how to get the first output.