Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Collections.Generic;
using System.Linq;
public class Person {
public string Name { get; set; }
public int Age { get; set; }
public string City { get; set; }
}
class Program {
static void Main() {
var people = new List<Person> {
new Person { Name = "Alice", Age = 25, City = "New York" },
new Person { Name = "Bob", Age = 30, City = "London" },
new Person { Name = "Charlie", Age = 35, City = "New York" }
};
var adults = people
.Where(p => p.Age >= 30)
.OrderBy(p => p.Name)
.Select(p => new { p.Name, p.Age })
.ToList();
foreach (var person in adults) {
Console.WriteLine($"{person.Name} is {person.Age} years old");
}
}
}Coding works best on desktop or with an external keyboard.