ValeraT1982 / ObjectsComparer

C# Framework provides mechanism to compare complex objects, allows to override comparison rules for specific properties and types.
MIT License
352 stars 86 forks source link

Comparison of Generic objects #11

Closed alexander9999 closed 4 years ago

alexander9999 commented 4 years ago

i have a question to ObjectsComparer. i have a Dto base type and some sub class type, say, base type "Person" and "Student" and "Professor", Student and "Professor" derive from Person with their own Properties. A Method has a Parameter of type Person, now i want to compare the argument with a another object, with could be Person, Student or Professor, how to compare the argument with the object with ObjectsComparer?

ValeraT1982 commented 4 years ago

@alexander9999, I'm not sure that I fully understand the question. I guess if you want to compare objects as Person (compare only fields/properties from Person) you can create comparer like this:

var comparer = new Comparer<Persone>();