【问题标题】:How to get elements from collection A that not in collection B? i.e. A-B [duplicate]如何从集合 A 中获取不在集合 B 中的元素?即 A-B [重复]
【发布时间】:2009-05-26 10:55:36
【问题描述】:

可能重复:
Disjoint Union in LINQ

欺骗Disjoint Union in LINQ

我知道这是一个简单的收集操作,我的代码是:

var gone = from a in A
     where B.Contains(a) == false
     select a;

但它不起作用。

【问题讨论】:

  • 感谢 Marc 挥动 Mod Hammer ;)

标签: c# linq collections


【解决方案1】:
var gone = A.Except(B);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-28
    • 2019-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多