C#判断两个List的交集与差集

  List<string> productLabelList = new List<string>();
            productLabelList.Add("传统");
            productLabelList.Add("分保");
            productLabelList.Add("涉密");
            productLabelList.Add("123");
            productLabelList.Add("1234");
            productLabelList.Add("888");
            productLabelList.Add("999");

            List<string> sgProductList = new List<string>();
            sgProductList.Add("传统");
            sgProductList.Add("分保");
            sgProductList.Add("涉密");

             var isexsist = productLabelList.Intersect(sgProductList); //交集 表示两个List都存在的集合
            
             var isexsist = productLabelList.Except(sgProductList).Distinct();//差集 表示productLabelList存在sgProductList不存在的集合


版权声明:本文为loginnamess原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。