Is there a general way to detect if a property’s type is an enumerable type?

Your code doesn’t actually check if the properties are Enumerable types but if they are generic IList’s. Try this:

if(typeof(IEnumerable).IsAssignableFrom(p.PropertyType))
{
   System.Windows.Forms.MessageBox.Show(p.Name);
}

Or this

if (p.PropertyType.GetInterfaces().Contains(typeof(IEnumerable)))
{
    System.Windows.Forms.MessageBox.Show(p.Name);
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)