Hi,
I have a list of objects that I would like to search for dupluicates based on several criteria. Simplified example below:
Now I would like to iterate through the list and find any duplicates. The criteria for a duplicate is the same age and the same surname - the address and forename is irrelevant.
I can do this with looping but think that using the generic List's .Find() method would be more elegant. Unfortunately any examples (including MSDN) are not clear where the matching criteria is passed in.
Any advice greatly appreciated.
Thanks,
Graeme
PS - I know the scenario I've presented is a bit nonsensical so please don't ask why I would want to find all 'Bloggs' that are same age!
"Just beacuse you're paranoid, don't mean they're not after you
I have a list of objects that I would like to search for dupluicates based on several criteria. Simplified example below:
Code:
List<Person> people = new List<Person>();
Person p1 = new Person("Joe", "Bloggs", 29, "1 Elm Street");
Person p2 = new Person("Mike", "Bloggs", 30, "2 Another Street");
Person p3 = new Person("Joe", "Bloggs", 29, "1 Elm Street");
people.Add(p1);
people.Add(p2);
people.Add(p3);
Now I would like to iterate through the list and find any duplicates. The criteria for a duplicate is the same age and the same surname - the address and forename is irrelevant.
I can do this with looping but think that using the generic List's .Find() method would be more elegant. Unfortunately any examples (including MSDN) are not clear where the matching criteria is passed in.
Any advice greatly appreciated.
Thanks,
Graeme
PS - I know the scenario I've presented is a bit nonsensical so please don't ask why I would want to find all 'Bloggs' that are same age!
"Just beacuse you're paranoid, don't mean they're not after you