new String[] { "vendor_id", "vendor_code", "vendor_name", "vendor_site" });
来自:
选择DataTable中的唯一值(Distinct)
开发中经常用到筛选DataTable等数据源中的唯一值(类似SQL中Distinct的返回结果),在.NET FX 1.x下我是这写的:
再后来又这样写:
1
static DataTable SelectDistinct(string ReturnTableName, DataTable SourceTable, string ReturnFieldName, string AdditionalFilterExpression)
2
后来这样写:2
1
private DataTable SelectDistinct(DataTable sourceTable, string sourceColumn)
2
2
再后来又这样写:
1
object[] distinctRoomType = GetDistinctValues(dt,"Roomtype");
2
3
Here is the method definition.
4
5
public object[] GetDistinctValues(DataTable dtable,string colName)
6
现在.NET FX 2.0中只要一句就可以搞定了,方便了许多:
2
3
4
5
6
1
);