How to get all names and values of any object using reflection and recursion
问题 I am trying to get a property names and values from an instance of an object. I need it to work for objects that contain nested objects where I can simple pass in the the parent instance. For example, if I have: public class ParentObject { public string ParentName { get; set; } public NestedObject Nested { get; set; } } public class NestedObject { public string NestedName { get; set; } } // in main var parent = new ParentObject(); parent.ParentName = "parent"; parent.Nested = new NestedObject