c# - Should I extract this code out into methods? -


i using reflection values , pass object property.

should refactor out few methods? if so, should refactor out each call. type, property etc.

//base item var item = aitem;  //the type of item var type = item.gettype();  //the property -- in example list of strings -- can list<int> etc. var property = type.getproperty("strings");  //the type of property var propertytype = property.propertytype;  //value converted value object var value = property.getvalue(item);  //new value changing type -- showing list of list -- using when had list<object> //var newvalue = convert.changetype(value, propertytype);  //the object property listdata = value; 

methods should contain code executes one task. in code given. returns content of list object via reflection.

in opinion should leave @ that. create method this:

object getlistdata(object item){     //your code     return value;  } 

Popular posts from this blog