1234567891011121314151617181920212223242526272829303132333435 |
- using System;
- class Client
- {
- public string Name { get; set; }
- public int Age { get; set; }
- public Client(string name, int age)
- {
- Name = name;
- Age = age;
- }
- }
- class Program
- {
- static void Main()
- {
- List<Client> users = new List<Client>
- {
- new Client("Маша", 18),
- new Client("Алиса", 23),
- new Client("Саша", 30),
- new Client("Вова", 25),
- new Client("Алена", 37)
- };
- var result = users
- .OrderBy(u => u.Name)
- .ThenBy(u => u.Age);
- foreach (Client u in result)
- Console.WriteLine($"{u.Name} - {u.Age}");
- }
- }
|