1.  取交集 (A和B都有)

List A : { 1 , 2 , 3 , 5 , 9 }
List B : { 4 , 3 , 9 }
var intersectedList = list1.Intersect(list2);
结果 : { 3 , 9 }
判断A和B是否有交集 bool isIntersected = list1.Intersect(list2).Count() > 0

2. 取差集 (A有,B沒有)
List A : { 1 , 2 , 3 , 5 , 9 }
List B : { 4 , 3 , 9 }
 var expectedList = list1.Except(list2);
结果 : { 1 , 2 , 5 }
判断A和B是否有差集 bool isExpected = list1.Expect(list2).Count() > 0

 3.  取联集 (包含A和B)

var unionList =list1.Union(list2);

相关文章:

  • 2022-12-23
  • 2021-11-18
  • 2020-06-10
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2021-09-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案