How can I print out a list of students (from this dictionary) with a score above 40, please: I would like to use an "If", else statement. But, I need help with how to get the computer to pick the 2nd value pair; which is the score & check if it is greater than 40 or not, please.
Code:
Dictionary<string, int> studentResults = new Dictionary<string, int>();
studentResults.Add("Fred", 85);
studentResults.Add("Chris", 72);
studentResults.Add("Paul", 65);
studentResults.Add("Marcus", 50);
studentResults.Add("Ashley", 22);
foreach (var studentResult in studentResults)
{
Console.WriteLine("Student " + studentResult.Key + " has a mark of " + studentResult.Value);
}
// Print the list of students with scores above 40
// List of students with scores above "40" - Fred, Chris, Paul & Marcus.