List<string> ls1 =new List<string> { "a", "b", "c", "d" };

List<string> ls2 = new List<string> { "a", "c", "d" ,"e"};

// 交集: a c d
ls1.Intersect(ls2);

// 差集: b
ls1.Except(ls2);

// 超集、合集:a b c d e
ls1.Union(ls2);

// 串聯: a b c d a c d e
ls1.Concat(ls2);

另一種思路:

// 差集:b
ls1.Where(l => !ls2.contains(l)).ToArray();

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
相关资源
相似解决方案