Getting values from dictionary
I have a Dictionary<int, int> in my class. How can I access both values without knowing the key?
For instance, I want to be able to do something like this: If the dictionary contains Dictionary&l开发者_如何学Pythont;int, int>
and the values are <5, 4> I want to be able to get the value of <(this),(this)> likePseudo code:
foreach(Dictionary item or row)
{
my first int = Dictionary<(this), (not this)>
my second int = Dictionary<(not this), (this)>
}
How can I do this using a dictionary? If this is not doable: Is there another way?
foreach (KeyValuePair<int, int> kvp in myDictionary)
{
var first = kvp.Key;
var second = kvp.Value;
}
精彩评论