datatable 添加同一类型的datatable,字典添加数据

 DataTable dt = new DataTable();

DataTable newDataTable = new DataTable();

//添加dt中的数据 到 newDataTable 中
foreach (DataRow dr in dt.Rows)
{
newDataTable.Rows.Add(dr.ItemArray);
}

 

 

 

 Dictionary<string, List<Data>> tabDatas = new Dictionary<string, List<Data>>();

for (int i = 0; i < datas[0].Count; i++)
{
List<Data> data1 = new List<Data>();

for (int j = 0; j < datas.Count; j++)
{
data1.Add(datas[j][i]);
}
tabDatas[datas[0][i].Time.ToString()] = data1;  //datas[0][i].Time.ToString()为key ,不重复,当key 重复时,将value值覆盖之前的value,不会报错
}

posted @ 2018-06-21 17:37  安相遇  阅读(226)  评论(0编辑  收藏  举报