开发者

Is there a <NotIn> LINQ method?

Is there a NotIn LINQ method ?

// A: 1,2,3,4,5
// B: 4,5,6,7,8
开发者_Python百科
C = A.NotIn(B);

// C: 1,2,3


IEnumerable<T>.Except

var a = new int[] {1, 2, 3, 4, 5};
var b = new int[] {4, 5, 6, 7, 8};
var c = a.Except(b);
foreach(var x in c)
    Console.WriteLine(x);

output:

1
2
3


Yes it is. It's called Except.

So in your case, C = A.Except(B);


That will be Except (assuming A and B are enumerable):

var C = A.Except(B);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜