lundi 12 septembre 2016

C# using reflection to get type of a the objects in a list

I have a class that contains a list of another class. How do i get the properties of the other class from just the list?

Im currently doing something like this:

private string ChildString(Type type)
    {
        string temp = "";
        foreach (var prop in type.GetProperties())
        {
            if (typeof(IList).IsAssignableFrom(prop.PropertyType))
            {
                //How do i get the properties here?
            }
            if (prop.PropertyType.IsClass && prop.PropertyType.Assembly.FullName == typeof(T).Assembly.FullName)
            {
                temp += prop.Name;
                ChildString(prop.PropertyType);
            }
        }
        return temp;
    }





Aucun commentaire:

Enregistrer un commentaire