示例#1
0
//-----------------------------

        private static void GetResults(Attributes.EyeColour eyes, Attributes.HairColour hair)
        {
            var school  = InitSchool();
            var results = school.GetMatchingStudents(eyes, hair);

            if (results.Count > 0)
            {
                Console.WriteLine($"Found {results.Count} student/s with {eyes.ToString().ToLower()} eyes and {hair.ToString().ToLower()} hair: ");
                foreach (var result in results)
                {
                    Console.WriteLine($"{result.Attributes.Name}, {result.Attributes.Age}");
                }
            }
            else
            {
                Console.WriteLine($"No results found for children with {eyes} eyes and {hair} hair");
            }
        }
示例#2
0
        public List <Student> GetMatchingStudents(Attributes.EyeColour eyes, Attributes.HairColour hair)
        {
            var results = Students.Where(m => m.Attributes.Eyes == eyes).Where(m => m.Attributes.Hair == hair);

            return(results.ToList());
        }