我正在創建一個程序,將學生和他們的分數存儲在字典列表混合中。例如,我需要用for循環創建新列表C#
Dictionary<int, List<int>> examGrades = new Dictionary<int, List<int>>();
List<int> name = new List<int>();
有無論如何使用for循環來爲新學生創建新列表嗎? 當我例如
Console.WriteLine("What is the student name");
string name = Console.ReadLine();
List<int> name = new List<int>();
編寫代碼在這種情況下,我會得到一個錯誤的無法創建,因爲「名稱」已經存在。無論如何要解決這個問題呢?這將在嵌套for循環的內循環中。 outer for循環會遍歷並將項添加到當前列表中。任何幫助,將不勝感激。謝謝。
只需調用其他名稱? – TZHX