コード例 #1
0
        static void main()
        {
            List <EmployeeD> empList = new List <EmployeeD>();

            empList.Add(new EmployeeD()
            {
                ID = 101, Name = "Adi", Salary = 20000, Experience = 2
            });
            empList.Add(new EmployeeD()
            {
                ID = 102, Name = "Fasil", Salary = 25000, Experience = 5
            });
            empList.Add(new EmployeeD()
            {
                ID = 103, Name = "Jishnu", Salary = 10000, Experience = 2
            });
            empList.Add(new EmployeeD()
            {
                ID = 104, Name = "Ashraf", Salary = 20000, Experience = 6
            });

            //instance of the delegate
            IsPromotable isPromotable = new IsPromotable(Promote);

            //calling the function
            EmployeeD.PromoteEmployee(empList, isPromotable);
        }
コード例 #2
0
 //This is the function which does the logic for us
 //It has the same signature as that of the delegate
 public static bool Promote(EmployeeD emp)
 {
     if (emp.Experience >= 5)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }