Home > DeveloperSection > Forums > Use Union operator in Linq.
Norman Reedus
Norman Reedus

Total Post:45

Posted on    March-20-2016 11:04 PM


 1 Reply(s)
 222  View(s)
Rate this:
We want to use Union operator in Linq.  How to use this please help me.

aditya kumar Patel

Total Post:250

Posted on    March-20-2016 11:05 PM

The Union extension method requires two collections, one collection on which the Union method is invoked and a second collection,
 which is passed as a parameter. The Union method returns distinct elements from both the collections.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace Prototype


class Example


static void Main()


IList<string> List1 = new List<string>() { "aditya", "manoj", "komal", "karan", "tarun" };

IList<string> List2 = new List<string>() { "tarun", "ajay", "vimal", "vijay", "manoj" };

var result = List1.Union(List2);

foreach (string str in result)






Don't want to miss updates? Please click the below button!

Follow MindStick