mercredi 7 septembre 2016

create a generic list from a reflected type [duplicate]

This question already has an answer here:

I am trying to create a generic list from a type that i have reflected but i get warning of "you use type like a varible"

            Type ty=item.GetType();
            PropertyInfo[]  cp = ty.GetProperties();
            foreach (PropertyInfo pitem in cp)
            {
                // I have a type with the same name of pitem.name
                Type t_type = Type.GetType(pitem.Name);
                List<t_type> t_list = new List<t_type>();

            }





Aucun commentaire:

Enregistrer un commentaire