title: Find average of collection of TimeSpans
body: <p>I have collection of TimeSpans, they represent time spent doing a task. Now I would like to find the average time spent on that task. It should be easy but for some reason I'm not getting the correct average.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>private TimeSpan? GetTimeSpanAverage(List&lt;TimeSpan&gt; sourceList)
  {
      TimeSpan total = default(TimeSpan);
  
      var sortedDates = sourceList.OrderBy(x =&gt; x);
  
      foreach (var dateTime in sortedDates)
      {
          total += dateTime;
      }
      return TimeSpan.FromMilliseconds(total.TotalMilliseconds/sortedDates.Count());
  }
  </code></pre>