标签:.net 重复数据 blog ams data default tab 数据 efault
有时需要从DataTable中抽取Distinct数据,遍历比较费劲,C#.NET中其实有更易用的方法,如下:
string[] columnArray = { "columnName1", "columnName2" };
DataView dataView = dataTable.DefaultView;
dataTable = dataView.ToTable(true, columnArray);
或者
DataView dataView = dataTable.DefaultView;
dataTable = dataView.ToTable(true, "columnName1", "columnName2");
ToTable的去重方法定义如下:
public DataTable ToTable(bool distinct, params string[] columnNames);
public DataTable ToTable(string tableName, bool distinct, params string[] columnNames);
标签:.net 重复数据 blog ams data default tab 数据 efault
原文地址:http://www.cnblogs.com/makesense/p/6236694.html