How to remove duplicates from a list of custom objects, by a property of the object [duplicate]
问题 This question already has answers here : LINQ's Distinct() on a particular property (21 answers) Closed 4 years ago . I want to remove the duplicates based on a property of my object: public class MyType { public string _prop1; public string _prop2; public LocationsClass(string prop1, string prop2) { _prop1= prop1; _prop2= prop2; } } ... List<MyType> myList; So basically I want to remove all MyType objects from myList, with the same value in _prop1. Is there a way to do this, probably with