title: C# How do I use dictionaries and lists with user input?
body: <p>I am building on a project that I already created. This is my first attempt at using dictionaries/lists. This a very broad question, as the book I have does not cover using dictionaries at all, and I am having trouble finding examples of dictionaries with user input online. I have made a program using a multidimensional array that asks the user for a number of students and a number of exams, then has the user enter scores for each exam, and outputs each students average grade based on their exam scores. I now want to achieve the same thing, only using dictionaries and lists instead of arrays. I don't even know where to begin. Can anyone explain how this would work? Here is the code I already have created, though it probably will not be helpful at all:</p>
  
  <pre><code>class MainClass
  {
      public static void Main(string[] args)
      {
          int TotalStudents = 0;
          int TotalGrades = 0;
  
          Console.WriteLine("Enter the number of students: ");
          TotalStudents = Convert.ToInt32(Console.ReadLine());
  
          Console.WriteLine("Enter the number of exams: ");
          TotalGrades = Convert.ToInt32(Console.ReadLine());
  
          int[,] scoresArray = new int[TotalStudents, TotalGrades];
  
          for (int r = 0; r &lt; TotalStudents; r++)
              for (int c = 0; c &lt; TotalGrades; c++)
              {
              Console.Write("Please enter exam score {0} for student {1}: ", c + 1, r + 1);
                  scoresArray[r, c] = Convert.ToInt32(Console.ReadLine());
              }
          for (int r = 0; r &lt; scoresArray.GetLength(0); r++)
          {
              int studentSum = 0;
              int testCount = 0;
              for (int c = 0; c &lt; scoresArray.GetLength(1); c++)
              {
                  studentSum += scoresArray[r, c];
                  testCount++;
              }
              string gradeLetter = "";
              double average = studentSum / testCount;
              Console.WriteLine("\nStudent " + (r + 1).ToString() + " Average Score: " + average.ToString());
  
              if (average &gt;= 90)
              {
                  gradeLetter = "A";
              }
              else if (average &gt;= 80 &amp;&amp; average &lt; 90)
              {
                  gradeLetter = "B";
              }
              else if (average &gt;= 70 &amp;&amp; average &lt; 80)
              {
                  gradeLetter = "C";
              }
              else if (average &gt;= 60 &amp;&amp; average &lt; 70)
              {
                  gradeLetter = "D";
              }
              else
              {
                  gradeLetter = "F";
              }
  
              Console.WriteLine("Student " + (r + 1).ToString() + " will recieve a(n) " + gradeLetter + " in the class.\n");
          }
          Console.Write("\nPress the [ENTER] key to exit.");
          Console.ReadLine();
      }
  }
  </code></pre>