Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
175 lines (147 loc) · 5.56 KB
/
Copy pathProgram.cs
File metadata and controls
175 lines (147 loc) · 5.56 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProfessionalCSharp10
{
class Program
{
//static async Task Main()
//{
// //var intList = new List<int>();
// var racers=new List<Racer>();
// List<int> intList=new List<int>(10);
// intList.Capacity = 20;
// intList.TrimExcess();
// var intList2=new List<int>();
// intList2.Add(1);
// intList2.Add(2);
// var stringList=new List<string>();
// stringList.Add("one");
// stringList.Add("two");
// var graham=new Racer(7,"Graham","Hill","UK",14);
// var emerson = new Racer(7, "Graham", "Hill", "UK", 14);
// var mario = new Racer(7, "Graham", "Hill", "UK", 14);
// var racers2 = new List<Racer>(20){ graham,emerson,mario};
// racers2.Add(new Racer(24,"a","b","c",25));
// racers2.Add(new Racer(21,"a","b","c",22));
// racers2.Insert(3,new Racer(6,"Pjil","Hill","USA",3));
// racers2.RemoveAt(3);
// int index = racers2.IndexOf(mario);
// RacerComparer racerComparer = new RacerComparer(RacerComparer.CompareType.Country);
// racers2.Sort(racerComparer);
// var dm=new DocumentManager();
// Task processDocuments = ProcessDocuments.Start(dm);
// for (int i = 0; i < 1000; i++)
// {
// var doc=new Document($"Doc{i.ToString()}","content");
// dm.AddDocument(doc);
// Console.WriteLine(doc.Title);
// await Task.Delay(new Random().Next(20));
// }
// await processDocuments;
// Console.ReadLine();
// var alphabet = new Stack<char>();
// alphabet.Push('A');
// alphabet.Push('B');
// alphabet.Push('C');
// foreach (char item in alphabet)
// {
// Console.WriteLine(item);
// }
// Console.WriteLine();
// while (alphabet.Count>0)
// {
// Console.WriteLine(alphabet.Pop());
// }
// Console.WriteLine();
// var pdm=new PriorityDocumentManager();
// pdm.AddDocument(new Document("a","b",1));
// pdm.AddDocument(new Document("a", "b", 2));
// pdm.AddDocument(new Document("a", "b", 3));
// pdm.AddDocument(new Document("a", "b", 4));
// pdm.AddDocument(new Document("a", "b", 5));
// pdm.DisplayAllNodes();
// #region 有序列表
// var books=new SortedList<string, string>();
// books.Add("a","1");
// books.Add("b","2");
// books.Add("c","3");
// books["d"] = "4";
// foreach (var book in books)
// {
// Console.WriteLine($"{book.Key},{book.Value}");
// }
// foreach (var title in books.Keys)
// {
// Console.WriteLine(title);
// }
// #endregion
//}
static void Main()
{
var companyTeams=new HashSet<string>(){"A","b","c"};
var traditionalTeams=new HashSet<string>(){"a1","b1","c1"};
var privateTeams=new HashSet<string>(){"a2","b2","c2"};
if (privateTeams.Add("williams"))
{
Console.WriteLine("w add");
}
if (!companyTeams.Add("McLaren"))
{
Console.WriteLine("mclaren set");
}
if (traditionalTeams.IsSubsetOf(companyTeams))
{
Console.WriteLine("tarditionalTeams is subset of companyTeams");
}
if (companyTeams.IsSubsetOf(traditionalTeams))
{
Console.WriteLine("companyTeams is a superset of traditionalTeams");
}
traditionalTeams.Add("Williams");
if (privateTeams.Overlaps(traditionalTeams))
{
Console.WriteLine("At least one team is the same with traditional and private teams");
}
var idJimmie=new EmployeeId("C48");
var jimmie=new Employee(idJimmie,"Jimmie Johnson",150926.00m);
var idJoey=new EmployeeId("F22");
var joey=new Employee(idJoey,"Joey Logano",45125.00m);
var employees=new Dictionary<EmployeeId,Employee>(31)
{
[idJimmie]=jimmie,
[idJoey]=joey
};
foreach (var employee in employees.Values)
{
Console.WriteLine(employee);
}
while (true)
{
Console.WriteLine("Enter employee id (X to exit)> ");
var userInput = Console.ReadLine();
userInput = userInput.ToUpper();
if (userInput=="X") break;
EmployeeId id;
try
{
id=new EmployeeId(userInput);
if (!employees.TryGetValue(id,out Employee employee))
{
Console.WriteLine($"{id} 不存在");
}
else
{
Console.WriteLine(employee);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
}