How do i make sure that List<T>.Contains(T) works with my custom class?
问题 I use .net 2.0 (C#) I have a Person class, and i pupulate List< Person> p from the database. i know for a fact that my list has duplicates, but when i try to remove the duplicates they don't get removed. Does my Person class need to implement any interfaces for List< T>.Contains(T) to work properly? Any other ideas? Thank you. 回答1: Your Person class should implement IEquatable 回答2: You should override Equals and GetHashCode method. 回答3: The example you reference is not a solution for removing