title: Average value of list
body: <p>I want to make code that will on the first click start <code>rotorSpeed</code> stopwatch then on the second click add <code>rotorSpeed.ElapsedMilliseconds</code> to <code>list</code>. On the second click resets stopwatch and starts timing again, then on the third click again adds <code>rotorSpeed.ElapsedMilliseconds</code> to <code>list</code>.
  There are no errors in the code, but when I debug it, I get an error on <code>double average = list.Average();</code></p>
  
  <p><code>Stopwatch rotorSpeed = new Stopwatch();
   List&lt;double&gt; list = new List&lt;double&gt;();</code></p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      i++;
      //Getting rotor speed
      if (i != 2)
      {               
          if (rotorSpeed.IsRunning)
          {
              rotorSpeed.Stop();
              list.Add(rotorSpeed.ElapsedMilliseconds);
              rotorSpeed.Start();                   
          }
          else
          {
              rotorSpeed.Reset();
              rotorSpeed.Start();
          }
      }
  
      double average = list.Average();
      textBox2.Text = average.ToString();
  }
  </code></pre>
  
  <p>This is the error I get:</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.InvalidOperationException' occurred in >System.Core.dll</p>
    
    <p>Additional information: Sequence contains no elements</p>
  </blockquote>