zoukankan      html  css  js  c++  java
  • DataTable 过滤重复行

       /// <summary>
            /// 去除重复数据
            /// </summary>
            /// <param name="table"></param>
            /// <returns></returns>
            public DataTable FilterRepeatTable(DataTable table)
            {
    
                DataTable _table = table.Clone();
                foreach (DataRow row in table.Rows)
                {
                    //field1要去除重复的字段,可以是多个字段
                    //int rowCount = (from DataRow q in _table.Rows where q["field1"].ToString() == row["field1"].ToString() && q["field2"].ToString() == row["field2"].ToString() select q).ToList().Count();
                    int rowCount = (from DataRow q in _table.Rows where q["SBMCBH"].ToString() == row["SBMCBH"].ToString() select q).ToList().Count();
                    if (rowCount == 0)
                    {
                        DataRow _row = _table.NewRow();
                        _row.ItemArray = row.ItemArray;
                        _table.Rows.Add(_row);
                    }
                }
                return _table;
            }
    View Code
  • 相关阅读:
    tcpdump 筛选抓包
    TCP拥塞避免
    【转载】TCP协议
    go 参数传递的是值还是引用 (转)
    go 数组指针 指针数组
    go 协程
    go 接口实现
    go函数可见性
    go 继承
    go 结构体函数
  • 原文地址:https://www.cnblogs.com/zyx321/p/6739510.html
Copyright © 2011-2022 走看看