Program.cs 708 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. class Client
  3. {
  4. public string Name { get; set; }
  5. public int Age { get; set; }
  6. public Client(string name, int age)
  7. {
  8. Name = name;
  9. Age = age;
  10. }
  11. }
  12. class Program
  13. {
  14. static void Main()
  15. {
  16. List<Client> users = new List<Client>
  17. {
  18. new Client("Маша", 18),
  19. new Client("Алиса", 23),
  20. new Client("Саша", 30),
  21. new Client("Вова", 25),
  22. new Client("Алена", 37)
  23. };
  24. var result = users
  25. .OrderBy(u => u.Name)
  26. .ThenBy(u => u.Age);
  27. foreach (Client u in result)
  28. Console.WriteLine($"{u.Name} - {u.Age}");
  29. }
  30. }