我有List<Dictionary<string, string>>
對象,其中包含一些數據。從列表中獲取唯一值<Dictionary <string,string >>
/* Values in the list will be like
[0] -
aaa - aaaValue1 (Key, Value)
bbb - bbbValue1
ccc - cccValue1
ddd - dddValue1
[1] -
aaa - aaaValue2 (Key, Value)
bbb - bbbValue2
ccc - cccValue2
ddd - dddValue2
and so on */
我想在字典中,以獲得不同的值(List<string>
),其中的關鍵是等於「CCC」,並將鍵「BBB」的值等於「bbbValue1」。
預期結果:
返回一個字符串列表包含字典中值,其中關鍵是等於「CCC」,並將鍵「BBB」的值等於「bbbValue1」在List<Dictionary<string, string>>
。
這將返回IEnumberable的'序列'不'名單' ..所以你應該在'.Distinct()' –
之後添加'.ToList()'。我的回答後問題發生了變化。 – Dima
@Dima對不起。我只問了一個新問題。但由於倒票,我不得不刪除它,所以我修改了這個問題。 –