I am trying to merge two lists using list.Union
in LinqPad
but I can\'t get it to work and wanted to check my understanding is correct.
Giv
You can create a class implementing
IEqualityComparer
Is this class define Equals and GetHashCode After it you can pass this comparer to you Union method Just like that:
public class MyComparer:IEqualityComparer{
//Equals and GetHashCode
}
var mergedList = list.Union(list2, new MyComparer()).ToList();