나는 다음과 같은 코드를 가지고 : 이제사전 목록을 반복하는 방법은 무엇입니까?
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)
가 어떻게 키 값에 액세스 할을? 내가 뭔가 잘못하고 있는거야?
미상의'allMnths' 어디에서 온? –
나중에 1 달이 필요하다는 것을 알고 있습니다. :) 그러나 'Error 'System.Collections.Generic.Dictionary '에'Key '에 대한 정의가없고'Key '확장 메서드가 없습니다. 'System.Collections.Generic.Dictionary '형식의 첫 번째 인수를 수락 할 수 있습니다 (사용 지시문이나 어셈블리 참조가 누락 되었습니까?) \t '문자열을 사용하려고 할 때. –
@ lazyberezovsky 나는 그가 문법 오류가 있다고 생각한다. –