车神

专注MS.NET技术
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

对datatable筛选重复数据

Posted on 2008-04-17 14:56  车神  阅读(440)  评论(0)    收藏  举报

string[] temp = null;
if (tb.Rows.Count > 0)
{
     //对重复的数据进行筛选
     Hashtable ht = new Hashtable();
     foreach (DataRow dr in tb.Rows)
     {
          string s = dr["originalName"];
          if (!ht.Contains(s))
              ht[s] = dr["originalName"];
     }
    
temp = new string[ht.Count];
     ht.Keys.CopyTo(temp, 0);
}