I have a class Employee, with some basic params, and a class employees that has a list of employee objects. I want to use the func delegate in the class employees to be able to use the following lambda expression in the main class. I think I have some syntax mistakes here... I'am getting the following error message: "cannot convert lambda expression to type 'Employee' because it is not a delegate type".
Someone knows what I'am doing wrong?
Many thanks guys !!
static void Main(string[] args)
{
Employees lijst = new Employees();
lijst.Add(new Employee("B1", 200));
lijst.Add(new Employee("B2", 100));
lijst.Add(new Employee("B3", 300));
lijst.Wijzig((Employee b) => b.Salary += 100);
Console.ReadKey();
}
class Employee
{
public String Name { get; set; }
public int Salary { get; set; }
public Employee(String Name, int Salary)
{
this.Name = Name;
this.Salary = Salary;
}
}
class Employees
{
public Func<Employee, int> Wijzig = new Func<Employee, int>(Change);
private ArrayList _lijst = new ArrayList();
public void Add(Employee e)
{
_lijst.Add(e);
}
static int Change(Employee b)
{
return 0;
}
}
Wizjigsupposed to do, anyway? What's its purpose?