I would like to access to all string properties of an object that has defined classes which also have string properties to apply a certain treatment. For example :
public class Class1
{
public string String1 {get; set;}
public Class2 class2 {get; set;}
}
public class Class2
{
public string String2 {get; set;}
}
Here, I would like to have a property list which contains String1 and String2
For the moment I know how to access to String1 :
var instanceOfClass1 = new Class1();
var stringsList = instanceOfClass1.GetType().GetProperties().Where(prop => prop.PropertyType == typeof(string))
But this won't access to String2.
Thank you in advance if you have any idea.
Aucun commentaire:
Enregistrer un commentaire