c# list链表去除重复数据-hashset转list

c# list链表去除重复数据

采用哈希代码类

 List<string> bb_list = new List<string> { "aa","aa","b", "b", "b" ,"c","c"};
        private void RemoveRepeatItem()
        {
            HashSet<string> aa = new HashSet<string>(bb_list);
            int abc = aa.Count();
        }

 

List<int> list = new List<int>();
list.Add(5);
list.Add(2);
list.Add(1);
list.Add(1);
HashSet<int> hs = new HashSet<int>(list);
list = new List<int>(hs);

posted @ 2022-07-27 10:07  txwtech  阅读(252)  评论(1编辑  收藏  举报