I have a dictionary
public Dictionary<string, List<string>> myDic = new Dictionary<string, List<string>>(2)
{
{"Key1", new List<string> {"Val1", "Val2", "Val3"} },
{"Key2", new List<string> {"Val4", "Val5"} }
};
I want to loop through the keys with the count of values for each key.
I have tried
foreach (string key in myDic.Keys)
{
for (int i = 0; i < myDic.Values.Count; i++)
{
//do something
}
}
which is obviously not working but I can't think of a better way.
//do something has to be executed for the keys a specific number of times as per the number of values. How can I go about this?
Listitems are you thinking there are in the Dictionary forKey1andKey2? For those two items, I only see one item in each of them. Perhaps your test/sample data is setup incorrectly with missing double-quotes ?