-
Об'єднання команд і гравців (Join)
Завдання: Уяви базу даних футбольних команд. У тебе є дві колекції: команди з ID та назвою; гравці з ID команди, ім'ям та голами. Використовуй Join для об'єднання, щоб отримати список гравців з назвою їхньої команди, фільтруй гравців з >10 голами, сортуй за голами (за спаданням) і спроектуй у тип {Команда, Гравець, Голи}.
Дані: 3 команди (Динамо Київ, Шахтар Донецьк, Металіст Харків); 5 гравців з голами.
Очікуваний результат: Список з 3 гравцями, наприклад: Шахтар Донецьк: Михайло Коваленко (20 голів). -
Множинні операції з наборами пісень (Union/Intersect/Except)
Завдання: У тебе є дві колекції пісень: рок з назвами та роками; поп з назвами та роками. Використовуй Union для всіх унікальних пісень, Intersect для спільних (кросовери), Except для рок-пісень, яких немає в поп. Спроектуй у {Назва, Рік}, сортуй за роком (за зростанням).
Дані: Рок: Stairway to Heaven (1971), Bohemian Rhapsody (1975), Smells Like Teen Spirit (1991); Поп: Bohemi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // для компіляції додайте nuget-пакети через View > Terminal: | |
| // dotnet add package Serilog --version 4.3.0 | |
| // dotnet add package Serilog.Sinks.Console --version 6.1.1 | |
| // dotnet add package Serilog.Sinks.File --version 7.0.0 | |
| using Serilog; | |
| namespace LoggingExample | |
| { | |
| class Program |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Diagnostics; | |
| using Microsoft.Extensions.Logging; // dotnet add package Microsoft.Extensions.Logging.Console --version 9.0.0 | |
| namespace LoggingExample | |
| { | |
| class Program | |
| { | |
| static async Task Main() | |
| { | |
| Console.OutputEncoding = System.Text.Encoding.UTF8; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Text.Json; | |
| using System.Text.Json.Serialization; | |
| using System.Text.Encodings.Web; | |
| namespace JSONSerializerExample | |
| { | |
| public class Human | |
| { | |
| public string? Name { get; set; } | |
| [JsonIgnore] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Xml.Serialization; | |
| namespace XMLSerializerExample | |
| { | |
| // [Serializable] // в нових версіях дот нет цей атрібут вже не обов'язковий | |
| public class Human | |
| { | |
| public string? Name { get; set; } | |
| [XmlIgnore] | |
| public int Age { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections.Generic; | |
| using System.Text; | |
| namespace SuperHeroExample | |
| { | |
| public class Human : IEquatable<Human> | |
| { | |
| // приватні поля для зберігання даних | |
| private string name; | |
| private int age; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Text; | |
| using MessagePack; // dotnet add package MessagePack | |
| namespace SerializationExample | |
| { | |
| // Every serializable non-static field and a property needs to be annotated | |
| // with the [Key] attribute. If you annotate the type with | |
| // the [MessagePackObject(keyAsPropertyName: true)] attribute, then members | |
| // don't require explicit annotations. In such case, to ignore certain | |
| // public members, use the [IgnoreMember] attribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Text; | |
| using System.Reflection; | |
| namespace Attributes | |
| { | |
| class Program | |
| { | |
| static void Main() | |
| { | |
| Console.OutputEncoding = Encoding.UTF8; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Linq; | |
| using System.Text; | |
| public class Creature | |
| { | |
| public string Name { get; set; } // назва істоти | |
| public bool Flying { get; set; } // літає? | |
| public bool Ranged { get; set; } // стріляє на відстані? | |
| public int Attack { get; set; } // атака | |
| public int Defense { get; set; } // захист |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Linq; | |
| using System.Text; | |
| using System.Xml.Linq; | |
| class Program | |
| { | |
| static void Main() | |
| { | |
| Console.OutputEncoding = Encoding.UTF8; |
NewerOlder