LINQ Except() Method Does Not Work
问题 I have 2 IList<T> of the same type of object ItemsDTO . I want to exclude one list from another. However this does not seem to be working for me and I was wondering why? IList<ItemsDTO> related = itemsbl.GetRelatedItems(); IList<ItemsDTO> relating = itemsbl.GetRelatingItems().Except(related).ToList(); I'm trying to remove items in related from the relating list. 回答1: Since class is a reference type, your ItemsDTO class must override Equals and GetHashCode for that to work. 回答2: From MSDN: