如果我有一个列表List<KeyValuePair<string,string>> ex。

["abc","123"]
["asc","123"]
["asdgf","123"]
["abc","123"]

如何区分这个 list ?

最佳答案

KeyValue区分:

var results = source.Distinct().ToList();

KeyValue区分(只需更改GroupBy调用的属性即可:
var results = source.GroupBy(x => x.Key).Select(g => g.First()).ToList();

关于c# - 如何区分键/值对列表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17955886/

10-11 21:32