public static bool IsCollection(this Type type)
{
if (type == null)
{
throw new ArgumentNullException("type", "type cannot be null.");
}
return (typeof(Array).IsAssignableFrom(type)
|| typeof(IEnumerable).IsAssignableFrom(type))
&& !typeof(string).IsAssignableFrom(type)
&& !typeof(byte[]).IsAssignableFrom(type);
}