I would like to load data from my txt file and store them in a 2D double array. I was trying something like this:
String input = File.ReadAllText(@"E:\c\vstup.txt");
int k = 0, l = 0;
double[][] resultout = new double[52][];
foreach (var row in input.Split('\n'))
{
l = 0;
foreach (var col in row.Trim().Split(' '))
{
resultout[k][l] = double.Parse(col.Trim());
l++;
}
k++;
}
It is not working. I am new in C#. Can anyone suggest how to do this? Thank you.
EDIT: It throws NullReferenceException at the line: resultout[k][l] = double.Parse(col.Trim());