将List <double>转换为DataTable需要花费大量时间

时间:2015-06-29 16:23:04

标签: c# list datatable

我正在为我的客户构建一个小软件,他们需要从3 list<double>读取数据。每个列表包含大约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;

问题是我正在成功读取数据,但需要很长时间才能读取数据。我写的代码有什么问题?

如果您有任何建议,请非常欢迎。

0 个答案:

没有答案
相关问题