Is there a cleaner way to get a list count using reflection then this?
Boolean include = false;
foreach (PropertyInfo item in props)
{
var pt = item.PropertyType;
String listType = pt.GetGenericArguments()[0].Name;
// Is there a better solution than this?
switch (listType)
{
case "jsonResult":
var list = v as List<jsonResult>;
include = list.count > 0;
break;
}
}
)
I've tried a variety of ideas from Googling but haven't had any luck.
Aucun commentaire:
Enregistrer un commentaire