Let's say I have a POCO:
public class Person
{
public string Name { get; set; }
public DateTime DateOfBirth { get; set; }
public IList<Person> Relatives { get; set; }
}
I want to compare two instances of Person to see if they're equal to each other. Naturally, I would compare Name
, DateOfBirth
, and the Relatives
collection to see if they're equal. However, this would involve me overriding Equals()
for each POCO and manually writing the comparison for each field.
My question is, how can I write a generic version of this so I don't have to do it for each POCO?