Linq forgetful stuff

Linq forgetful stuff

Union

List<int> collectionOne = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

List<int> collectionTwo = new List<int>() { 1, 2, 3, 11, 12, 13, 14, 15 };  

var unionResult = collectionOne.Union(collectionTwo);  

result: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ,11 ,12 , 13 ,14 ,15


Intersect


List<int> collectionOne = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };  

List<int> collectionTwo = new List<int>() { 1, 2, 3, 11, 12, 13, 14, 15 }; 

var IntersectResult = collectionOne.Intersect(collectionTwo);  

result: 1, 2, 3


Except


List<int> collectionOne = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };  

List<int> collectionTwo = new List<int>() { 1, 2, 3, 11, 12, 13, 14, 15 };  

var exceptResult = collectionOne.Except(collectionTwo);  

result: 4, 5, 6, 7, 8, 9, 10