DataTable去除重复行

时间:2021-11-18 05:22:34

//抽取dt中的特定列"Region","Cur","Year"组合成新的dat

DataTable dat = dt.DefaultView.ToTable(false, new string[]{ "Region","Cur","Year" });

DataView dv = new DataView(w_dt); //虚拟视图吧,我这么认为

//去除dv中的重复行并组合成新的dt2,dt2就是去除重复行后的DataTable

DataTable dt2 = dv.ToTable(true, "Region", "Cur", "Year");