2013-06-09 14 views

답변

1

네, 가능합니다. Enumerable.Except이라고합니다.

사용이 :

var result = listA.Except(listB); //maybe a .ToList() at the end, 
//or passing an IEqualityComparer<T> if you want a different equality comparison. 
3

나도 listA에없는 그 listB에서 항목을 포함 지금까지 답변을하지 않습니다. 에게 중 하나 목록에있는 아이템을 얻을 수 있지만 모두 목록입니다하려면

listA.Union(listB).Except(listA.Intersect(listB)); 
+0

, 당신은 또한'listA.Except을 (할 수 listB) .Union (listB.Except (listA)) ' –

+0

+1, 그것은 내 것보다 나은 대답입니다. –

1

가장 효율적인 대안으로

var set = new HashSet<T>(listA); 
set.SymmetricExceptWith(listB);