我有以下代码:
List<Dictionary<string, string>> allMonthsList = new List<Dictionary<string, string>>();
while (getAllMonthsReader.Read()) {
Dictionary<string, string> month = new Dictionary<string, string>();
month.Add(getAllMonthsReader["year"].ToString(),
getAllMonthsReader["month"].ToString());
allMonthsList.Add(month);
}
getAllMonthsReader.Close();
现在我正在尝试遍历所有月份,如下所示:
foreach (Dictionary<string, string> allMonths in allMonthsList)
如何访问键值?难道我做错了什么?