LINQ Set Operations

In LINQ, Set Operators are used to return the set of the result 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. These are:

  1. UNION
  2. INTERSECT
  3. DISTINCT
  4. EXCEPT
LINQ Set Operations

All these set operators will perform as the different operators like removing duplicate elements from the collections or combine all the elements of the collections or leave some elements from the collection based on our requirement.

The following table shows more details related to set operators in LINQ.

OperatorsDescription
UNIONUnion operator combines multiple collections into single collection and return the resultant collection with unique element.
INTERSECTIt returns the element in a sequence, which is common in both the input sequence.
DISTINCTIt removes the duplicate elements from the collection and returns the collection with unique values.
EXCEPTIt returns the sequence element from the first input sequence, which is not present in the second input sequence.





Latest Courses