List集合去重复

 1             ///获取List的集合值
 2                 foreach (DataRow row in dt.Rows)
 3                 {
 4                     list.Add(row["HJMC"].ToString());
 5                 }
 6                 //list去重复
 7                 for (int i = 0; i < list.Count - 1; i++)
 8                 {
 9                     for (int j = list.Count - 1; j > i; j--)
10                     {
11                         if (list[j].ToString().Equals(list[i].ToString()))
12                         {
13                             list.Remove(list[j].ToString());
14                         }
15                     }
16                 }

 

posted @ 2014-07-09 15:47  流浪在阿尔卑斯的野狼  阅读(216)  评论(0编辑  收藏  举报