I have defined a CustomListComparer
which compares List<int> A
and List<int> B
and if Union
of the two lists equals at least on of the lists, considers them equal.
var distinctLists = MyLists.Distinct(new CustomListComparer()).ToList();
public bool Equals(Frame other)
{
var union = CustomList.Union(other.CustomList).ToList();
return union.SequenceEqual(CustomList) ||
union.SequenceEqual(other.CustomList);
}
For example, the below lists are equal:
ListA = {1,2,3}
ListB = {1,2,3,4}
And the below lists are NOT:
ListA = {1,5}
ListB = {1,2,3,4}
Now all this works fine. But here is my question: Which one of the Lists (A or B) gets into distinctLists
? Do I have any say in that? Or is it all handled by compiler itself?
What I mean is say that the EqualityComparer
considers both of the Lists equal. and adds one of them to distinctLists
. Which one does it add? I want the list with more items to be added.