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);
精彩评论