C#中可以利用反射解决,其代码如下:
class Judge
{
public static IsICollection(object o)
{
Type type = typeof(o);
Type t = type.GetInterface("ICollection", false);
if (object.Equals(type, null))
{
return false;
}
else
{
return true;
}
}
}