比较两个list

List<string> list1 = new List<string>() { "4ee","wf", "6yh", "gg", "wjjgf", "vvc" };

            List<string> list2 = new List<string>() { "p4ee","wpf", "6yph", "gg", "wjppjgf", "vpvc" };
            //首先 
            var tmp = list1.Concat(list2).ToList();//合并两个集合

            //分组找到重复数据
            var sameList = tmp.GroupBy(x => x)
                .Where(x => x.Count() > 1)
                .ToList();

            //找到不重复数据
            var uniqueList = tmp.GroupBy(x => x).ToList();

  

posted @ 2022-09-23 21:43  Nicolasap  阅读(26)  评论(0编辑  收藏  举报