A
Abhishek
Hi
I am using a generic list in my program to have a list of objects
stored. I want to compare all the objects in this list with object of
another class and find all the objects which meet the criteria.
To make it more specific
I have a class Employee and a class Salary which look like
Employee
{
Name
Salary
Age
Id
}
Salary
{
Currency
Amount
}
Now i am having a List<Employee> and when now what i want is to get a
List of Employees whose salary is greater then 2000.
One way to achieve this is to write a method in class Salary which
looks like
public bool IsGreaterThen2000(Employee obj)
{
//some logic
return true/false;
}
and then pass this as predicate to FindAll method however the
responsibility of comparison lies with Salary class. I want to shift
this responsibility to some other class which already has the logic
for comparison.
Is there a way to achieve this using existing generic List class
in .NET framework.
Any help would be highly appreciated.
Thanks, Abhishek
I am using a generic list in my program to have a list of objects
stored. I want to compare all the objects in this list with object of
another class and find all the objects which meet the criteria.
To make it more specific
I have a class Employee and a class Salary which look like
Employee
{
Name
Salary
Age
Id
}
Salary
{
Currency
Amount
}
Now i am having a List<Employee> and when now what i want is to get a
List of Employees whose salary is greater then 2000.
One way to achieve this is to write a method in class Salary which
looks like
public bool IsGreaterThen2000(Employee obj)
{
//some logic
return true/false;
}
and then pass this as predicate to FindAll method however the
responsibility of comparison lies with Salary class. I want to shift
this responsibility to some other class which already has the logic
for comparison.
Is there a way to achieve this using existing generic List class
in .NET framework.
Any help would be highly appreciated.
Thanks, Abhishek