Difference between two lists

前端 未结 12 1345
无人共我
无人共我 2020-11-22 13:19

I Have two generic list filled with CustomsObjects.

I need to retrieve the difference between those two lists(Items who are in the first without the items in the sec

12条回答
  •  被撕碎了的回忆
    2020-11-22 13:34

            List list1 = new List();
            List list2 = new List();
            List listDifference = new List();
    
            foreach (var item1 in list1)
            {
                foreach (var item2 in list2)
                {
                    if (item1 != item2)
                        listDifference.Add(item1);
                }
            }
    

提交回复
热议问题