[C#] DataTable 操作汇总(持续更新)
1、DataTable 分组操作
var grow = dt.Select().GroupBy((row1) => { return new { //分组的字段 fieldA = row1["a"].ToString(), fieldB = row1["b"].ToString() }; }).ToList(); foreach(var item in grow) { string aa = item.Key.fieldA; string bb = item.Key.fieldB; IEnumerator<DataRow> rows = item.GetEnumerator();//var rows = item.GetEnumerator(); 也可以 while(rows.MoveNext()) { DataRow dr = rows.Current; } }