I have the following two methods
/// <summary>
/// Reports the number of students in each ClassLevel designation
/// </summary>
/// <param name="students">The original collection of students</param>
/// <returns>A Dictionary where the key is the ClassLevel and the value is the number of students in that level</returns>
public static Dictionary<ClassLevel, int> StudentsPerClassLevel(this IEnumerable<Student> students)
{
var query = students.GroupBy(student => student.Level).ToDictionary(x => x.Key, x => x.Count());
return query;
}
/// <summary>
/// Determines which MaritalStatus has the highest average GPA
/// </summary>
/// <param name="students">The original collection of students</param>
/// <returns>The MaritalStatus value with the highest average GPA</returns>
public static MaritalStatus MaritalStatusWithHighestAverageGPA(this IEnumerable<Student> students)
{
var query = students.GroupBy(s => s.Relationship).ToDictionary(x => x.Key, x => x.Average(g => g.GPA)).OrderByDescending(d => d.Value).First().Key;
return query;
}
None of these methods work, I am trying to figure out where I went wrong and what I need to do in order to get what I am trying to achieve.
Any suggestions?