If I create a 2d array like so:
int[,] MyArray = new int[5, 5];
and have a text file with these numbers:
1 2 3 4 5
5 4 3 2 1
1 2 3 4 5
2 3 4 6 7
7 8 9 6 4
How do I get the numbers into the 2d array?
string[] line = text.split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < line.Length; i++)
{
string[] digit = text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
for (int j = 0; j < digit.Length; j++)
{
MyArray[i, j] = Convert.ToInt32(digit[j]);
}
}