I want to get the names of all the properties that have been changed to match the objects. I have these (simplified) classes:
public enum PersonType { Student, Professor, Employee } class Person { public string Name { get; set; } public PersonType Type { get; set; } } class Student : Person { public string MatriculationNumber { get; set; } } class Subject { public string Name { get; set; } public int WeeklyHours { get; set; } } class Professor : Person { public List<Subject> Subjects { get; set; } }
Now I want to get objects whose values ββare different:
List<Person> oldPersonList = ... List<Person> newPersonList = ... List<Difference> = GetDifferences(oldPersonList, newPersonList); public List<Difference> GetDifferences(List<Person> oldP, List<Person> newP) {
In the end, I would like to have a Difference list as follows:
class Difference { public List<string> ChangedProperties { get; set; } public Person NewPerson { get; set; } public Person OldPerson { get; set; } }
ChangedProperties must contain the name of the changed properties.
comparison c # properties
juergen d
source share