So I have a dictionary that is set up like:
Dictionary<DateTime, List<Double>>
The date and times are months I pull from an excel spreadsheet and then my integers is the dollar amount. The columns look like this:
7/1/10 | 6/1/10
----------------
100.00 | 90.00
----------------
3.00 | 20.00
----------------
35.00 | 10.00
and so on and so forth for about 6 months. I need to get these keys and the values. I need to put it into my database. For example for the values 100.00, 3.00, 35.00 they all coordinate with month 7/1/10 (the first key has the 3 Values under it and etc.)
Could someone just show me how to iterate over these things? When I debugged my dictionary put's all the info in correctly but I can't pull them back out.
Just iterate them directly in a nested loop
Dictionary<DateTime, List<Double>> map;
foreach (var pair in map) {
DateTime dt = pair.Key;
foreach (double value in pair.Value) {
// Now you have the DateTime and Double values
}
}
foreach(KeyValuePair<DateTime,List<Double> pair in dictionaryName){
DateTime dt = pair.Key;
List<Double> doubleList = pair.Value;
//With this method you now can step through each key value pair
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With