title: Getting average value of groups with LINQ
body: <p>I am trying to split my List into different groups based on a certain value each item in the List has, and then find the average of another value in those groups. </p>
  
  <p>To better put it, I have a list of Students: </p>
  
  <pre><code>List&lt;Student&gt; students = new List&lt;Student&gt; {
      new Student { Name="Bob", Level=Level.Sophomore, GPA=3.2f },
      new Student { Name="Cathy", Level=Level.Freshman, GPA=3.6f },
      new Student { Name="James", Level=Level.Senior, GPA=3.8f },
      new Student { Name="Jessica", Level=Level.Senior, GPA=3.7f },
      new Student { Name="Derek", Level=Level.Junior, GPA=2.8f },
      new Student { Name="Sam", Level=Level.Junior, GPA=3.1f }
  };
  </code></pre>
  
  <p>And I want to group them by their Class Level, so they'll be grouped into Freshman, Sophomore, Junior, and Senior. And then I want to be able to get the Average GPA for those groups. </p>
  
  <p>So a possible result set for these students would be:</p>
  
  <pre><code>Senior: 3.7
  Junior: 2.9
  Sophomore: 3.2
  Freshman : 3.6
  </code></pre>
  
  <p>I'm not quite too sure how to go about getting this result though. I have tried things like <code>students.GroupBy(x =&gt; x.Level).Average();</code> but it does not work. </p>
  
  <p>Any thoughts on this would be greatly appreciated. Thank you!</p>