我想删除此列表中的重复项:
List<Dictionary<string, object>> val = new List<Dictionary<string, object>>();
Run Code Online (Sandbox Code Playgroud)
如果我以这种方式应用Distinct(),它不起作用:
List<Dictionary<string, object>> result = val.Distinct().ToList<Dictionary<string, object>>()
Run Code Online (Sandbox Code Playgroud)
更新:问题现在解决了.我使用MySQL union命令从数据库中读取表.
尝试这个:
List<Dictionary<string, object>> result = val.Distinct(new myDictionaryComparer()).ToList();
Run Code Online (Sandbox Code Playgroud)
其中myDictionaryComparer是Comparer Class。您可以在此类中实现比较逻辑。