コード例 #1
0
ファイル: delegate.cs プロジェクト: quandt162/At-Class
        static void Main(string[] args)
        {
            List <Employee> empList = new List <Employee>();

            empList.Add(new Employee()
            {
                ID = 101, NAME = "Quan1", SALARY = 1000, EXPERIENCE = 1
            });
            empList.Add(new Employee()
            {
                ID = 102, NAME = "Quan2", SALARY = 1500, EXPERIENCE = 3
            });
            empList.Add(new Employee()
            {
                ID = 103, NAME = "Quan3", SALARY = 2000, EXPERIENCE = 2
            });
            empList.Add(new Employee()
            {
                ID = 104, NAME = "Quan4", SALARY = 2500, EXPERIENCE = 4
            });

            ISPromote isPromoteable = new ISPromote(Promote);

            Employee.PromoteEmployee(empList, isPromoteable);

            // Employee.PromoteEmployee(empList, e => e.EXPERIENCE >= 5);

            Console.ReadLine();
        }
コード例 #2
0
ファイル: delegate.cs プロジェクト: quandt162/At-Class
 public static void PromoteEmployee(List <Employee> empList, ISPromote isEligibleToPromote)
 {
     foreach (Employee employee in empList)
     {
         if (isEligibleToPromote(employee))
         {
             Console.WriteLine(employee.NAME + " promoted");
         }
     }
 }