LINQ Set Operations (Distinct, Union, Intersect, Except)

  Total Views : 181
  Comments : 0
 
  Keywords : Linq set operators in c# / vb.net with example, Different type of linq set operations like distinct / union / intersect / except in c# / vb.net with examples

Here we will learn LINQ set operations in c#, vb.net with example and different types of LINQ set operations (union, intersect, distinct, except) in c#, vb.net with examples.

LINQ Set Operations

In LINQ Set Operators are used to return result set based on the presence or absence of equivalent elements within the same or separate collections.

 

In LINQ we have different type of set operators available those are:

 

  • UNION
  • INTERSECT
  • DISTINCT
  • EXCEPT

These set operators will perform different operators like removing duplicate elements from the collections or combine all the elements of collections or leave some elements from collection based on our requirements.

 

Following table shows more details related to set operators in LINQ.

 

OperatorDescription
UNION It combine multiple collections into single collection and return resultant collection with unique elements
INTERSECT It return sequence elements which are common in both the input sequences
DISTINCT It removes duplicate elements from the collection and returns collection with unique values
EXCEPT It returns sequence elements from first input sequence that are not present in second input sequence

In coming chapters we will more about each set operator in detail with examples.

 

PREVIOUS

LINQ Group Join
 
 

 Comments (0)

Be the first to give your valuable feedback

Leave a comment

  • Default Tutlane User