samedi 11 août 2018

Get all string properties of an object and any descendent objects

Given any complex object, for example:

public class Person
{
    public string Name {get;set;}
    public Address Address {get;set;}
}

public class Address
{
    public string Street {get;set;}
    public string City {get;set;}
}

I want to use reflection to obtain all the strings for instance of Person and any child objects, in this case Address, and theoretically any potential objects in Address etc. In this example this would retrieve PropertyInfo for Person.Name, Address.Street, and Address.City





Aucun commentaire:

Enregistrer un commentaire