c# list中的removeAll方法 两个List集合去除交集部分

static List<Object> list = new List<Object>() { 1,2,4,"a","b"};
        static List<Object> list1 = new List<Object>() { 1, 2, 3,"a","c" };
        static void Main(string[] args)
        {
            list1.RemoveAll(it => list.Contains(it));
            foreach (Object i in list1)
            {
                Console.WriteLine(i);
            }
            Console.ReadKey(); 

  

posted @ 2019-07-24 09:30  巴蒂尔  阅读(8580)  评论(0编辑  收藏  举报