今天被这个问题纠结了好一会。如果去除重复荐,判断是否重复的条件是有两个,一个信息来源,一个是信息标题。
最后使用了哈希后很好的解决,感觉挺高效的。代码贴下,做一个备忘
//防止群发,出现重复通知,去除重复项 private List<UserEmail> GetNotRepeatSentingEmail(List<UserEmail> LSentingEmail) { List<UserEmail> Result = new List<UserEmail>(); Hashtable hash = new Hashtable(); Result.Clear(); hash.Clear(); for (int i = 0; i < LSentingEmail.Count; i++) { if (!hash.ContainsKey(LSentingEmail[i].T_To) && !hash.ContainsValue(LSentingEmail[i].T_Subject)) { hash.Add(LSentingEmail[i].T_To, LSentingEmail[i].T_Subject); Result.Add(LSentingEmail[i]); } } return Result; }
原文:http://www.cnblogs.com/cxeye/p/3581906.html