© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
3 replies
Alizer

❔ I need help making a `diff` of 2 objects of the same class

I have a complex class like below
public class Person {
  public string Name { get; set; }

  public byte Age { get; set; }

  public List<Person>? Children { get; set; }

// many other properties omitted
}
public class Person {
  public string Name { get; set; }

  public byte Age { get; set; }

  public List<Person>? Children { get; set; }

// many other properties omitted
}

Now, I have 2 instances of this class
Person
Person
and I want to get the differences between both, my problem is the
Person
Person
class is a really complex class, it has around 20+ properties, some properties are collections, I made a class like below to record the differences
public class Difference {
  public string PropertyPath { get; set; }

  public object OriginalValue { get; set; }

  public object NewValue { get; set; }
}
public class Difference {
  public string PropertyPath { get; set; }

  public object OriginalValue { get; set; }

  public object NewValue { get; set; }
}

my question is, how do I start with this? if there is a library that does this automatically I would use it
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Need help making classes
C#CC# / help
2y ago
When 2 objects occupy the same cords , one kills the other , need help.
C#CC# / help
15mo ago
❔ Can separate class objects contain instances of the same method object
C#CC# / help
3y ago
(Beginner) Instantiate objects of a class at runtime
C#CC# / help
12mo ago