How to get the distinct data from a list?
问题 I want to get distinct list from list of persons . List<Person> plst = cl.PersonList; How to do this through LINQ . I want to store the result in List<Person> 回答1: Distinct() will give you distinct values - but unless you've overridden Equals / GetHashCode() you'll just get distinct references . For example, if you want two Person objects to be equal if their names are equal, you need to override Equals / GetHashCode to indicate that. (Ideally, implement IEquatable<Person> as well as just