static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); Family family = new Family(); for (int i = 0; i < n; i++) { string[] tokens = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries); string currentName = tokens[0]; int currentAge = int.Parse(tokens[1]); family.Add(new Person(currentName, currentAge)); } Person oldestPerson = family.GetOldestMember(); Console.WriteLine("{0} {1}", oldestPerson.Name, oldestPerson.Age); }
public static void Main() { int personCount = int.Parse(Console.ReadLine()); Family family = new Family(); for (int i = 0; i < personCount; i++) { string[] inputPerson = Console.ReadLine().Split(); string name = inputPerson[0]; int age = int.Parse(inputPerson[1]); Person person = new Person(name, age); family.Add(person); } var persons = family.Persons.Where(x => x.Age > 30).OrderBy(x => x.Name); foreach (var item in persons) { Console.WriteLine($"{item.Name} - {item.Age}"); } }