Hi,
I have to find an object of Employee (Say 'Empl') in a list of
objects of Employees (EmployeeList). The object Empl inturn has a list
of objects (say List of Children objects ) in it.
I have used Find method with predicate as follows,
Class Employee
{
string name;
List<Childrenchildrens; //Assume getters and setters
}
Class Children
{
string name;
int age;
}
Employee Match = EmployeeList.Find(new
comparision().FindComparision(Empl));
The predicate is something like this
public predicate<EmployeeFindComparision(Employee empl)
{
return delegate(Employee emplObj )
{
return( emplObj.Childrens.Equals(empl.Childrens));
};
}
But the issue is it always return false. I gues that we can not use
the Equals on the list the way i have used it.
Also the equals comparision that i need to do should be in the same
order. I mean if emplObj.Childrens have 3 children objects (say x, y,
z) and suppose empl.Childrens have 3 children objects (say m,n,o) then
the requirements is such that i have to check whether x is equal to m,
y is equal to n and z is equal to o.
Any inputs/code samples on how to achieve it directly using the List
or any other way like overriding the Equals method of Employee class
etc in an efficient way.
Any help is greatly apprieciated.
Thanks ,
Sachin