-
Notifications
You must be signed in to change notification settings - Fork 0
/
PatternMatchning.cs
48 lines (47 loc) · 1.57 KB
/
PatternMatchning.cs
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
namespace csharp_7_features_notes
{
public class PatternMatchning : ITestableClass
{
private static void DisplayPersonInfo(object person)
{
if (person is Manager manager)
{
Console.WriteLine($"Manager {manager.Name} ({manager.Email ?? "[no email]"}) is working on tasks {string.Join(",", manager.TasksCodes)}");
}
if (person is Programmer programmer)
{
Console.WriteLine($"Programmer {programmer.Name} ({programmer.Email ?? "[no email]"}) is skilled by {string.Join(",", programmer.SkillNames)}");
}
}
public void RunTest()
{
var manager = new Manager
{
Name = "Alex",
TasksCodes = new List<int> { 1, 2, 3, 4, 5 }
};
var programmer = new Programmer
{
Name = "Andrey",
Email = "andrey@aprogrammer.ru",
SkillNames = new List<string> { "C#", ".NET CORE", "ASP.NET", "SQL", "JavaScript", "VueJS", "Angular" }
};
DisplayPersonInfo(programmer);
DisplayPersonInfo(manager);
}
}
public class Manager
{
public string Name { get; set; }
public string Email { get; set; }
public List<int> TasksCodes { get; set; }
}
public class Programmer
{
public string Name { get; set; }
public string Email { get; set; }
public List<string> SkillNames { get; set; }
}
}