/
Program.cs
74 lines (48 loc) · 1.81 KB
/
Program.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
namespace Chapter6_Sets
{
class Program
{
static void Main(string[] args)
{
HashSet<string> showroom = new HashSet<string>(){
"Focus", "Mustang", "RX-8", "Mazda 3"
};
foreach(string car in showroom){
Console.WriteLine($"{car}");
}
showroom.Add("Mazda 3");
Console.WriteLine("---------------------------------");
foreach(string car in showroom){
Console.WriteLine($"{car}");
};
HashSet<string> usedCars = new HashSet<string>(showroom){
"F150", "Viper"
};
List<string> multipleCars = new List<string>(){
"Viper", "Viper", "F150", "F150", "Mustang", "Camaro"
};
HashSet<string> movedshowroom = new HashSet<string>(multipleCars);
movedshowroom.UnionWith(showroom);
Console.WriteLine("--------------------------------------");
movedshowroom.Remove("Mazda 3");
foreach(string car in movedshowroom){
Console.WriteLine($"{car}");
};
HashSet<string> clone = new HashSet<string>(movedshowroom);
HashSet<string> junkyard = new HashSet<string>(){
"Bronco", "Viper", "Altima", "Maxima", "Mustang"
};
clone.IntersectWith(junkyard);
Console.WriteLine("-------------------------------");
foreach(string car in movedshowroom){
Console.WriteLine($"{car}");
};
junkyard.UnionWith(movedshowroom);
foreach(string car in movedshowroom){
Console.WriteLine($"{car}");
};
}
}
}