In LINQ, Set Operators are useful to return result set based on the presence or absence of equivalent elements within the same or separate collections.
In LINQ, we have different types of set operators available those are:
These set operators will perform different operators like removing duplicate elements from the collections or combining all the elements of collections, or leaving some elements from the collection based on our requirements.
The following table shows more details related to set operators in LINQ.
|UNION||It combines multiple collections into a single collection and returns a resultant collection with unique elements.|
|INTERSECT||It returns sequence elements that are common in both the input sequences|
|DISTINCT||It removes duplicate elements from the collection and returns them with unique values.|
|EXCEPT||It returns sequence elements from the first input sequence not present in the second input sequence.|
In the coming chapters, we will discuss each set operator in detail with examples.