Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 转换列表<;双倍>;创建数据表需要很多时间_C#_List_Datatable - Fatal编程技术网

C# 转换列表<;双倍>;创建数据表需要很多时间

C# 转换列表<;双倍>;创建数据表需要很多时间,c#,list,datatable,C#,List,Datatable,我正在为我的客户构建一个小软件,他们需要从3列表中读取数据。每个列表包含大约50000个数据点,它们将列表作为一个数组提供给我: List<double>[] MyVars = new List<double>[3]; for (int x = 0; x < 3; x++) { string tempRowCell = ""; tempRowCell = grdMaapingView.GetRowCellValue(0, grdMaa

我正在为我的客户构建一个小软件,他们需要从3
列表中读取数据。每个列表包含大约50000个数据点,它们将列表作为一个数组提供给我:

List<double>[] MyVars = new List<double>[3];
for (int x = 0; x < 3; x++)
{
    string tempRowCell = "";
    tempRowCell = grdMaapingView.GetRowCellValue(0,
        grdMaapingView.VisibleColumns[x].FieldName).ToString();
    grdMaapingView.GetRowCellValue(x,
        grdMaapingView.VisibleColumns[x].Name.ToString());
    MyModifiedTable.Columns.Add(tempRowCell, typeof(string));
    MyVars[x] = Pressin.GetValuesByFilter(tempRowCell).Values.ToList(); 
}

for (int c = 0; c < MyModifiedTable.Columns.Count; c++)
{
    foreach (double v in MyVars[c])
    {
        string temp = MyModifiedTable.Columns[c].ColumnName.ToString();
        DataRow TempRow = MyModifiedTable.NewRow();
        TempRow[temp] = v;
        MyModifiedTable.Rows.Add(TempRow);
    }
}

grdResults.DataSource = MyModifiedTable.DefaultView;
List[]MyVars=新列表[3];
对于(int x=0;x<3;x++)
{
字符串tempRowCell=“”;
tempRowCell=grdMaapingView.GetRowCellValue(0,
grdMaapingView.VisibleColumns[x].FieldName.ToString();
grdMaapingView.GetRowCellValue(x,
grdMaapingView.VisibleColumns[x].Name.ToString();
MyModifiedTable.Columns.Add(tempRowCell,typeof(string));

MyVars[x]=Pressin.GetValuesByFilter(tempRowCell.Values.ToList(); } for(int c=0;c
问题是我正在成功读取数据,但读取数据需要75秒的时间。我写的代码有什么问题


如果您有任何建议,欢迎提供。

不会花那么长时间的。我建议您精确地对代码进行基准测试(使用
Stopwatch
类),以确定代码的哪一部分占用了大部分时间。先生,我已经使用了Stopwatch类,时间就是我如何获得75秒,你不觉得这么多钱有点太多了吗data@user4281377:代码的哪个部分比较慢?MyVars[x]=按in.GetValuesByFilter(tempRowCell.Values.ToList();然后您应该对GetValuesByFilter进行基准测试。