In the above example, "Kapil" and "Amit" names are available in both delhiResidents and kolkataResidents collections classes. When we use Union operator it will take all elements but include "Kapil" and "Amit" at only one time.

By default, union operator does not work with Custom Types. It does not differentiate whether two types are equal or not. For this scenario, we need to create a new comparer class which implements IEqualityComparer interface. This interface has two methods Equals and GetHashCode. Both methods are compulsory to implement.