I have a .txt file like this:
1,2,3,4,5
6,7,8,9,10
11,12,13,14,15
16,17,18,19,20
I want to read this file to an double array with PLinq with this code:
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Text Files(*.txt)|*.txt";
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
number_of_users = File.ReadAllLines(ofd.FileName).Length;
number_of_services = File.ReadAllLines(ofd.FileName)[0].Split(',').Length;
quality_of_service_array = new double[number_of_users, number_of_services];
quality_of_service_array = File.ReadAllLines(ofd.FileName)
.Select(l => l.Split(',').Select(i => double.Parse(i)).ToArray())
.ToArray();
}
This array should have 4 rows and 5 columns.
But I get this error:
Cannot implicitly convert type 'double[][]' to 'double[,].
I know the meaning of this error but I'm not expert in PLinq.