using System.Linq; List phones = new List() { new Item("Iphone SE 2020", 24000), new Item("Nokia 3310", 2000), new Item("Samsung Galaxy S24", 90000), new Item("Samsung Z Fold5", 65000), new Item("Iphone 15 Pro Max", 139000), new Item("Iphone X", 32000), new Item("Xiaomi 12T Pro", 60000) }; /* 1 var sorted = phones.OrderBy(x => x.title).ThenByDescending(x => x.price); foreach (var a in sorted) { Console.WriteLine(a.title +" - "+ a.price); } */ /* 2 var averageprice = phones.Select(u =>u.price).Average(); Console.WriteLine(averageprice); */ /* 3 var sorted = phones.Where(u => u.title.StartsWith("Samsung")); foreach (var a in sorted) { Console.WriteLine(a.title); } Console.WriteLine(); var sorted2 = phones.Where(u => u.title.StartsWith("Iphone")); foreach (var a in sorted2) { Console.WriteLine(a.title); } */ /* 4 var phoneslist = phones.OrderBy(x => x.price); foreach (var x in phoneslist) { Console.WriteLine(x.title +" - "+ x.price); } */ var newlist = phones.Where(u => u.price < 50000).Select(u => u); Console.WriteLine("Смартфоны дешевле 50000:"); foreach (var a in newlist) { Console.WriteLine(a.title +"-"+ a.price); } public class Category { public string title { get; set; } public Category(string title) { this.title = title; } } public class Item { public string title { get; set; } public Category category { get; set; } public string description { get; set; } public double price { get; set; } public Item (string title, double price) { this.title = title; this.price = price; } } public abstract class Person { public string firstName { get; set; } public string lastName { get; set; } public int age { get; set; } public Person(string firstName, string lastName, int age) { this.firstName = firstName; this.lastName = lastName; this.age = age; } } public class Worker : Person { public double salary { get; set; } public string position { get; set; } public Worker(string firstName, string lastName, int age, double salary, string position) : base(firstName, lastName, age) { this.salary = salary; this.position = position; } } public class Client : Person { public string numberPhone { get; set; } public Client(string firstName, string lastName, int age, string numberPhone) : base(firstName, lastName, age) { this.numberPhone = numberPhone; } }