title: c#, using .length method
body: <p>I have a method that needs to do a calculation based upon the length of an array. I am using the .length method for the calculation, but the method is doing arithmetic with the max length of the array (which I have declared as 10). This is the loop I am using to get data from the user. I know it isn't the ideal way to sort array data, but this is for a homework assignment, and it revolves around using the .Split method correctly (which isn't the problem I'm having).</p>
  
  <pre><code>for (int i = 0; i &lt; MAX; i++)
  {
      Console.Write("Enter a name and a score for player #{0}: ", (i + 1));
      string input = Console.ReadLine();
      if (input == "")
      {
          // If nothing is entered, it will break the loop.
          break; 
      }
  
      // Splits the user data into 2 arrays (integer and string).
      string[] separateInput = input.Split();
      name [i] = separateInput[0];
      score [i] = int.Parse(separateInput[1]);
  }
  </code></pre>
  
  <p>Here is the method I am using to calculate the average score:</p>
  
  <pre><code>static void CalculateScores(int[] score)
  {
      int sum = 0;
      int average = 0;
      for (int i = 0; i &lt; score.Length; i++)
      {
          sum += score[i];
          average = sum / score.Length;
      }
  
      Console.WriteLine("The average score was {0}", average);
  </code></pre>
  
  <p>I am calling the method like this:</p>
  
  <pre><code>    CalculateScores(score);
  </code></pre>
  
  <p>Edit: My arrays are declared:</p>
  
  <pre><code>    int[] score = new int[MAX]; //MAX == 10.
      string[] name = new string[MAX];
  </code></pre>
  
  <p>The CalculateScores method is doing the math as though score.Length is always 10, no matter how many different combinations of scores I input to the console. I can't figure out if it's because my loop to gather input has been done incorrectly, or my CalculateScores method is flawed. Thanks in advance.</p>
  
  <p>Edit: to clarify, I am just confused at why I can't get the correct value out of CalculateScores.</p>