How to remove duplicates from a list in C#
问题 I want to remove duplicates from this list: List<Dictionary<string, object>> val = new List<Dictionary<string, object>>(); It does not work if I apply Distinct() in this way: List<Dictionary<string, object>> result = val.Distinct().ToList<Dictionary<string, object>>() Update: Problem is now solved. I used the MySQL union command to read table from the database. 回答1: Try this: List<Dictionary<string, object>> result = val.Distinct(new myDictionaryComparer()).ToList(); where