title: Add a Median Method to a List
body: <p>I would like to override the List object in C# in order to add a Median method like Sum or Average. I already found this function:</p>
  
  <pre><code>public static decimal GetMedian(int[] array)
  {
      int[] tempArray = array;
      int count = tempArray.Length;
  
      Array.Sort(tempArray);
  
      decimal medianValue = 0;
  
      if (count % 2 == 0)
      {
          // count is even, need to get the middle two elements, add them together, then divide by 2
          int middleElement1 = tempArray[(count / 2) - 1];
          int middleElement2 = tempArray[(count / 2)];
          medianValue = (middleElement1 + middleElement2) / 2;
      }
      else
      {
          // count is odd, simply get the middle element.
          medianValue = tempArray[(count / 2)];
      }
  
      return medianValue;
  }
  </code></pre>
  
  <p>Can you tell me how to do that?</p>