11. Set Operations Flashcards
What does the Distinct
extension method do?
It returns only the distinct (unique) elements from a sequence.
eg. seq.Distinct();
What does the Intersect
extension method do?
It allows us to find items that occur in the both of two given sequences.
eg. seqA.Intersect(seqB);
What does the Union
extension method do?
It merges two given sequences and removes all duplicate values from the.
eg. seqA.Union(seqB);
What does the Except
extension method do?
From two given sequences, it returns the elements of the first sequence that don’t appear in the second sequence.
eg. seqA.Except(seqB);
How can you find the duplicate values in a given sequence?
Group the data by the duplicate property/value you’re looking for, and then filter by using the Count
method of the groupings to return all groups with the count of 2 or more.