コード例 #1
0
    // use delegates if you want to pass a method as a parameter to another method, use delegates
    // to make your methods and code reusable, use delegates
    public static void Main()
    {
        List <EmployeeDel> emplist = new List <EmployeeDel>();

        emplist.Add(new EmployeeDel()
        {
            ID         = 100,
            Ename      = "Geetha",
            Experience = 5,
            Salary     = 23000
        });
        emplist.Add(new EmployeeDel()
        {
            ID         = 101,
            Ename      = "Yedida",
            Experience = 2,
            Salary     = 2343242
        });
        emplist.Add(new EmployeeDel()
        {
            ID         = 102,
            Ename      = "Ye",
            Experience = 7,
            Salary     = 23643
        });
        ISPromotable prom = new ISPromotable(promote);

        EmployeeDel.PromoteEmployee(emplist, prom);
    }
コード例 #2
0
 public static void PromoteEmployee(List <EmployeeDel> employeelist, ISPromotable IsEligibleToPromote)
 {
     foreach (EmployeeDel emp in employeelist)
     {
         if (IsEligibleToPromote(emp))
         {
             Console.WriteLine(emp.Ename, "promoted");
         }
     }
 }
コード例 #3
0
 public static void Promote(List <Employeee> emplist, ISPromotable isEligiblePromotable)
 {
     foreach (Employeee empl in emplist)
     {
         if (isEligiblePromotable(empl))
         {
             Console.WriteLine("Promoted" + empl.Name);
         }
     }
 }
コード例 #4
0
        //public static void Main()
        //{
        public static void test()
        {
            List <Employeee> empList = new List <Employeee>();

            empList.Add(new Employeee()
            {
                ID = 101, Name = "A", Salary = 101, Experience = 1
            });
            empList.Add(new Employeee()
            {
                ID = 101, Name = "B", Salary = 101, Experience = 5
            });
            empList.Add(new Employeee()
            {
                ID = 101, Name = "C", Salary = 101, Experience = 6
            });

            ISPromotable isPromotable = new ISPromotable(Promoted);

            Employeee.Promote(empList, isPromotable);
        }