I have a text file that has:
1 2 3 4 0 5 6 7 8
How do I show the data in a 2D array of size [3,3]?
I'm new to C# and any help would be great!
I've tried the code below but it doesn't work:
int i = 0, j = 0;
int[,] result = new int[3, 3];
foreach (var row in input.Split('\n'))
{
j = 0;
foreach (var col in row.Trim().Split(' '))
{
result[i, j] = int.Parse(col.Trim());
j++;
}
i++;
}
Console.WriteLine(result);
it doesn't work?