如何在foreach循环中比较字典中的值 [英] How to compare values from dictionary in foreach loop
本文介绍了如何在foreach循环中比较字典中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含所有字段的Dictionary对象。
现在,我想比较字典中的字段(我正在更改字段值)。
下面是代码:
字典:
Hi,
I have a Dictionary object crated for all fields.
Now, i want to compare the field (I am changing the Field value) from the Dictionary.
Below is the code:
DICTIONARY:
Dictionary<string, Dictionary<string, Int32>> ID = new Dictionary<string, Dictionary<string, Int32>>()
GOT ALL FIELDS IN COLLECTION:
GOT ALL FIELDS INTO COLLECTION:
FieldCollection FC=(FieldCollection)this.#######.Fields;
foreach(var item in FC)
{
//How to compare the field from dictionary
}
我的尝试:
我试过谷歌搜索但无法得到它
What I have tried:
I tried googling but unable to get it
推荐答案
我假设从词典中取出字典名为ID就是你的
I have assumed that getting the dictionary out of the dictionary called ID is what you are after
foreach(KeyValuePair<string,>> pair in ID)
{
Dictionary<string,int> inner = pair.Value;
//You can now do what comparisons here you need to do on the dictionary.
}
这篇关于如何在foreach循环中比较字典中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文