c# 删除 DataTable 里面空行的算法
原创
©著作权归作者所有:来自51CTO博客作者ibmfashion的原创作品,请联系作者获取转载授权,否则将追究法律责任
List<DataRow> removelist = new List<DataRow>();
for (int i = 0; i < dt.Rows.Count; i++)
{
bool rowdataisnull=true;
for (int j = 0; j < dt.Columns.Count; j++) {
if (dt.Rows[i][j].ToString().Trim() != "") {
rowdataisnull = false;
}
}
if (rowdataisnull) {
removelist.Add(dt.Rows[i]);
}
}
for (int i = 0; i < removelist.Count; i++) {
dt.Rows.Remove(removelist[i]);
}