jeudi 25 février 2016

How to Get the Value of a List Type Property using propertyInfo

            Type objType = Model.GetType();
            PropertyInfo[] properties = objType.GetProperties();
            foreach (PropertyInfo property in properties)
            {
                object propValue;
                //Checking if property is indexed                 
                if(property.GetIndexParameters().Length ==0)
               propValue  = property.GetValue(Model,null);
                else
                {  
                 // want to retrieve collection stored in property index not passing 0 index returning element at 0 location ,how can i get whole list  
                 propValue = property.GetValue(objectModel,new Object[]{0});                       
                 }
                var elems = propValue as IList;

How can i get the Property Value of List Type, my property in the Model is a List Type for Example my Model contains a List Property

List<User>





Aucun commentaire:

Enregistrer un commentaire