-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKnowledge.cs
More file actions
79 lines (67 loc) · 1.86 KB
/
Copy pathKnowledge.cs
File metadata and controls
79 lines (67 loc) · 1.86 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AlgorithmPractice
{
public class Knowledge
{
public void TrySortInList()
{
Employee e1 = new Employee();
e1.Age = 50;
e1.Company = "io";
e1.FirstName = "9";
e1.LastName = "8";
Employee e2 = new Employee();
e2.Age = 52;
e2.Company = "io";
e2.FirstName = "92";
e2.LastName = "82";
Employee e3 = new Employee();
e3.Age = 54;
e3.Company = "io";
e3.FirstName = "93";
e3.LastName = "83";
Employee e4 = new Employee();
e4.Age = 54;
e4.Company = "io1";
e4.FirstName = "93";
e4.LastName = "83";
List<Employee> list = new List<Employee>();
list.Add(e1);
list.Add(e2);
list.Add(e3);
list.Add(e4);
list.Sort(CompareEmployee);
}
public int CompareEmployee(Employee x, Employee y)
{
if (x.Age > y.Age)
{
return 1;
}
else
{
return 0;
}
}
public void TryObjectContainInDictionary()
{
Dictionary<TreeNode, int> d = new Dictionary<TreeNode, int>();
TreeNode s = new TreeNode();
s.data = 8;
d.Add(s, 5);
TreeNode t = s;
bool flag1 = d.ContainsKey(s);//true
bool flag2 = d.ContainsKey(t);//true
bool flag3 = d.ContainsKey(new TreeNode(8));// no
}
public void tryArray()
{
int[] a = new int[] { };
a[0] = 8;// throw exception
}
}
}