C# implementation of deep/recursive object comparison in .net 3.5

后端 未结 6 2213
不思量自难忘°
不思量自难忘° 2020-11-27 16:36

I am looking for a C# specific , open source (or source code available) implementation of recursive, or deep, object comparison.

I currently have two graphs of live

6条回答
  •  忘掉有多难
    2020-11-27 17:12

    This is a complex area; I've done some things like this at runtime, and it quickly gets messy. If possible, you might find that the simplest way to do this is to serialize the objects and compare the serialized form (perhaps xml-diff and XmlSerializer). This is complicated a little by the types not being known until runtime, but not hugely (you can always use new XmlSerializer(obj.GetType()) etc).

    That would be my default approach, anyway.

提交回复
热议问题