説明なし

ebakhtin 5feab7901f commit 1 8 ヶ月 前
Program.cs 5feab7901f commit 1 8 ヶ月 前
readme.md 5feab7901f commit 1 8 ヶ月 前
t6_linq.csproj 5feab7901f commit 1 8 ヶ月 前
t6_linq.sln 5feab7901f commit 1 8 ヶ月 前

readme.md

### 1

var sorted = phones.OrderBy(x => x.title).ThenByDescending(x => x.price);
foreach (var a in sorted)
{
    Console.WriteLine(a.title +" - "+ a.price);
}
Iphone 15 Pro Max - 139000
Iphone SE 2020 - 24000
Iphone X - 32000
Nokia 3310 - 2000
Samsung Galaxy S24 - 90000
Samsung Z Fold5 - 65000
Xiaomi 12T Pro - 60000

2

var averageprice = phones.Select(u =>u.price).Average();
Console.WriteLine(averageprice);
58857,142857142855

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);
}
Samsung Galaxy S24
Samsung Z Fold5

Iphone SE 2020
Iphone 15 Pro Max
Iphone X

4

var phoneslist = phones.OrderBy(x => x.price);
foreach (var x in phoneslist)
{
    Console.WriteLine(x.title +" - "+ x.price);
}
Nokia 3310 - 2000
Iphone SE 2020 - 24000
Iphone X - 32000
Xiaomi 12T Pro - 60000
Samsung Z Fold5 - 65000
Samsung Galaxy S24 - 90000
Iphone 15 Pro Max - 139000

5

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);
}
Смартфоны дешевле 50000:
Iphone SE 2020-24000
Nokia 3310-2000
Iphone X-32000