生成解决方案时没有报错,调试报错:未处理的“System.FormatException”类型的异常出现在 mscorlib.dll 中。其他信息: 输入字符串的格式不正确。
请大神们帮我看看下面这个程序错在哪里了?
1.txt文档中数据如下:
-180.00 -55.8617
-179.90 -54.4839
-179.80 -53.5790
-179.70 -53.1470string patch1 = "E:\\data\\1.txt";
string[] line1 = File.ReadAllLines(patch1);
double[,] Eco_testdata = new double[line1.Length, 2];
for (int i = 0; i < Eco_testdata.GetLength(0); i++)
{
double[] linea1 = line1[i].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(T => double.Parse(T)).ToArray();//将patch1路径下文档中的每行进行以“ ”为分割,然后赋值给一维数组linea1
for (int j = 0; j < Eco_testdata.GetLength(1); j++)
{
Eco_testdata[i, j] = linea1[j];
}
}
请大神们帮我看看下面这个程序错在哪里了?
1.txt文档中数据如下:
-180.00 -55.8617
-179.90 -54.4839
-179.80 -53.5790
-179.70 -53.1470string patch1 = "E:\\data\\1.txt";
string[] line1 = File.ReadAllLines(patch1);
double[,] Eco_testdata = new double[line1.Length, 2];
for (int i = 0; i < Eco_testdata.GetLength(0); i++)
{
double[] linea1 = line1[i].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(T => double.Parse(T)).ToArray();//将patch1路径下文档中的每行进行以“ ”为分割,然后赋值给一维数组linea1
for (int j = 0; j < Eco_testdata.GetLength(1); j++)
{
Eco_testdata[i, j] = linea1[j];
}
}
/*
[0, 0] -180.0 double
[0, 1] -55.8617 double
[1, 0] -179.9 double
[1, 1] -54.4839 double
[2, 0] -179.8 double
[2, 1] -53.579 double
[3, 0] -179.7 double
[3, 1] -53.147 double */