title: How to calculate the rolling average of a C# array list?
body: <p>I'm trying to calculate the rolling averages of every four values in an array list and add those values to a separate array list. My original array list is called numlist and it contains values from 1 to 9</p>
  
  <pre><code>List&lt;int&gt; numlist = new List&lt;int&gt;();
  
  numlist.Add(1);
  numlist.Add(2);
  numlist.Add(3);
  numlist.Add(4);
  numlist.Add(5);
  numlist.Add(6);
  numlist.Add(7);
  numlist.Add(8);
  numlist.Add(9);
  </code></pre>
  
  <p>When it calculates rolling averages, it should do it in an way like this:</p>
  
  <p>first average = (1+2+3+4)/4</p>
  
  <p>second average = (2+3+4+5)/4</p>
  
  <p>third average = (3+4+5+6)/4</p>
  
  <p>and so on</p>
  
  <p>so the second array list,</p>
  
  <pre><code>List&lt;double&gt; avelist = new List&lt;double&gt;();
  </code></pre>
  
  <p>should contain these values</p>
  
  <pre><code>{2.5, 3.5, 4.5, 5.5, 6.5, 7.5}
  </code></pre>
  
  <p>How can I achieve this?</p>