-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdell.cs
54 lines (49 loc) · 1.74 KB
/
dell.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
using System;
using System.Collections.Generic;
namespace Delegates
{
public delegate void HelloFunctionDelegate(string Message);
class Program
{
public static void Main(string[] args)
{
List<Employee> emplist = new List<Employee>();
emplist.Add(new Employee() { ID = 101, Name = "Mary", Salary = 5000, Experience = 5 });
emplist.Add(new Employee() { ID = 111, Name = "Money", Salary = 4000, Experience = 2 });
emplist.Add(new Employee() { ID = 121, Name = "Mike", Salary = 6000, Experience = 4 });
emplist.Add(new Employee() { ID = 131, Name = "John", Salary = 2000, Experience = 6 });
emplist.Add(new Employee() { ID = 141, Name = "Todd", Salary = 3000, Experience = 3 });
IsPromotable isPromotable = new IsPromotable(Promote);
Employee.PromoteEmployee(emplist,isPromotable);
}
public static bool Promote(Employee emp)
{
if (emp.Experience >= 5)
{
return true;
}
else
{
return false;
}
}
}
delegate bool IsPromotable(Employee empl);
class Employee
{
public int ID { get; set; }
public string Name { get; set; }
public int Salary { get; set; }
public int Experience { get; set; }
public static void PromoteEmployee(List<Employee> employeelist,IsPromotable isEligableToromote)
{
foreach(Employee employee in employeelist)
{
if (isEligableToromote(employee))
{
Console.WriteLine(employee.Name + " promoted");
}
}
}
}
}