-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
54 lines (40 loc) · 1.29 KB
/
Copy pathProgram.cs
File metadata and controls
54 lines (40 loc) · 1.29 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
// See https://aka.ms/new-console-template for more information
using DesignPatterns.Strategy;
using DesignPatterns.Strategy.Sample;
Console.WriteLine("Hello, World!");
Context context;
//Injection
context = new Context(new ConcreteStrategyA());
context.ContextInterface();
//Injection
context = new Context(new ConcreteStrategyB());
context.ContextInterface();
//Injection
context = new Context(new ConcreteStrategyC());
context.ContextInterface();
//----------------Sample------------
Console.WriteLine("----------------Sample------------");
var users = new User[]
{
new User { Id = 101 ,Credit=5000,Name="Ehsan" ,LastName="Babaei"},
new User {Id = 105 ,Credit=8000,Name="Roshan" ,LastName="Ahmadi"},
new User {Id = 109,Credit=3000, Name="Ali" ,LastName="Ahmadi"},
};
Console.WriteLine("----------------Befor Sort------------");
foreach (var item in users)
{
item.DisplayUser();
}
Array.Sort(users, new UserByCredit_Comparer());
Console.WriteLine("----------------After Sort------------");
foreach (var item in users)
{
item.DisplayUser();
}
Array.Sort(users, new UserById_Comparer());
Console.WriteLine("----------------After Sort By Id------------");
foreach (var item in users)
{
item.DisplayUser();
}
Console.ReadLine();