title: Determine which method to call based on array size and number of arguments
body: <p>I have a heavy computational algorithm which I must complete. In order to make it as efficient as possible, I've broken it into five methods based on the number of arguments. This allows me to economize as best as possible. That said, I don't want my user to be aware of that.</p>
  
  <pre><code>public AnalysisResult[] PerformAnalysis(double[] Inputs, double[] Outputs, int[][] Coefficients)
  {
      AnalysisResult[] AR = new AnalysisResult[Coefficients.Length];
  
      for (int i = 0; i &lt; Coefficients.Length; i++)
          AR[i] = GetResults(Inputs, Outputs, /* Based on length of Coefficients[i]*/ );
  
      return AR;
  }
  
  private AnalysisResult GetResults(double[] Inputs, double[] Outputs, int A)
  {
      // Do stuff
  }
  
  private AnalysisResult GetResults(double[] Inputs, double[] Outputs, int A, int B)
  {
      // Do stuff
  }
  
  private AnalysisResult GetResults(double[] Inputs, double[] Outputs, int A, int B, int C)
  {
      // Do stuff
  }
  
  private AnalysisResult GetResults(double[] Inputs, double[] Outputs, int A, int B, int C, int D)
  {
      // Do stuff
  }
  
  private AnalysisResult GetResults(double[] Inputs, double[] Outputs, int A, int B, int C, int D, int E)
  {
      // Do stuff
  }
  </code></pre>
  
  <p>As you can see, I want to have only one public method available to the user for calling the algorithm. I'm wondering if there is an easy way to determine which one of the private methods to call based on the length of the array that is passed in to <code>PerformAnalysis</code>?</p>
  
  <p>Any suggestions?</p>
  
  <p>My approach up to this point has been a switch statement based on the length of the array, but I assume there is a better approach.</p>
  
  <pre><code>public AnalysisResult[] PerformAnalysis(double[] Inputs, double[] Outputs, int[][] Coefficients)
  {
      AnalysisResult[] AR = new AnalysisResult[Coefficients.Length];
  
      for (int i = 0; i &lt; Coefficients.Length; i++)
          switch (Coefficients[i].Length)
          {
              case 1:
                  AR[i] = GetResults(Inputs, Outputs, Coefficients[i][0]);
                  break;
              case 2:
                  AR[i] = GetResults(Inputs, Outputs, Coefficients[i][0], Coefficients[i][1]);
                  break;
  
              // Etc
          }                
  
      return AR;
  }
  </code></pre>