Javatpoint Logo
Javatpoint Logo

LINQ Union Method

In LINQ, the Union method or operator is used to combine the multiple collections into a single collection and return the resultant collection with a unique element.

Here is the pictorial representation of the LINQ Union Method.

LINQ Union() Method

Union method will combine both the collections into a single collection and return the unique elements from the collections by removing the duplicate elements.

Syntax of LINQ union Method

Here is the syntax of using the union method to get the unique elements from the multiple collections.

In the above syntax, we are combining two collections to get the result as a single collection using the union method.

Example of LINQ Union Method

Here is the example of using the LINQ Union Method.

In the above example, we are combining the two collections "count1","count2" using the union method to get the unique elements from both the collections.

OUTPUT:

LINQ Union() Method




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA