Kornfeld Eliyahu Peter is right in that you could use the index to access each value, although accessing a Dictionary by the index is not as simple as using
[i]
, you need to use
ElementAt
- remember a Dictionary is designed to be accessed via its Key
For example:
const string formatOutput = "Loop {0} : Cover Mean: {1}, {2}; Water Mark: {3}, {4}";
for (var i = 0; i < coverMeanDict.Count; i++)
{
Console.WriteLine(formatOutput, i,
coverMeanDict.Keys.ElementAt(i), coverMeanDict.Values.ElementAt(i),
Watermark_mean_dict.Keys.ElementAt(i), Watermark_mean_dict.Values.ElementAt(i));
}
Alternatively you can convert the Dictionaries to Lists (of KeyValuePairs) and use explicit indexing on the list. For example:
var coverMeanList = coverMeanDict.ToList();
var WaterMarkList = Watermark_mean_dict.ToList();
for (var j = 0; j < coverMeanList.Count; j++)
{
Console.WriteLine(formatOutput, j,
coverMeanList[j].Key, coverMeanList[j].Value,
WaterMarkList[j].Key, WaterMarkList[j].Value);
}