var resultList = list1.Intersect<XElement>(list2, new XElementComparer());
Why is the GetHashCode method of my XElementComparer never called?
When I check the content of the resultList I see:
System.Exeception object to set to an instance of an object
Both my lists have XElements. What do I wrong?
The
Intersectextension method returns anIEnumerable<>, but does not actually perform the intersection until you begin enumerating it (e.g. do aforeach, call.ToList()etc.). As such, I wouldn’t expect any of the methods on your comparer to be called based on the snippet you’ve given, since you aren’t enumerating the result.