我怎么会截然不同我的键/值对列表 [英] How would I distinct my list of key/value pairs
本文介绍了我怎么会截然不同我的键/值对列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个列表列表与LT; KeyValuePair<字符串,字符串>>
恩。
If I have a list List<KeyValuePair<string,string>>
ex.
["abc","123"]
["asc","123"]
["asdgf","123"]
["abc","123"]
我怎么能distinc这个名单?
how can I distinc this list?
推荐答案
由双方鲜明的键
和值
:
var results = source.Distinct().ToList();
按键
或<$ C $鲜明C>值(只是改变 GROUPBY
呼叫属性:
Distinct by Key
or Value
(just change the property on GroupBy
call:
var results = source.GroupBy(x => x.Key).Select(g => g.First()).ToList();
这篇关于我怎么会截然不同我的键/值对列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文