public static void ListGenericType(object list)
{
Type objType = list.GetType();
int count = (int)(objType.GetProperty("Count").GetValue(list, null));
for (int i = 0; i < count; i++)
{
object listItem = objType.GetProperty("Item").GetValue(list, new object[] { i });
foreach (PropertyInfo propertyInfo in listItem.GetType().GetProperties())
{
object value = propertyInfo.GetValue(listItem, null);
Console.WriteLine(propertyInfo.Name+"="+value);
}
}
}
{
Type objType = list.GetType();
int count = (int)(objType.GetProperty("Count").GetValue(list, null));
for (int i = 0; i < count; i++)
{
object listItem = objType.GetProperty("Item").GetValue(list, new object[] { i });
foreach (PropertyInfo propertyInfo in listItem.GetType().GetProperties())
{
object value = propertyInfo.GetValue(listItem, null);
Console.WriteLine(propertyInfo.Name+"="+value);
}
}
}