草庐IT

IMyCollInterface

全部标签

c# - 我怎么知道属性是否是通用集合

我需要使用PropertyInfo类知道类中属性的类型是否为泛型集合(List、ObservableCollection)。foreach(PropertyInfopin(o.GetType()).GetProperties()){if(pisCollection?????)} 最佳答案 TypetColl=typeof(ICollection);foreach(PropertyInfopin(o.GetType()).GetProperties()){Typet=p.PropertyType;if(t.IsGenericType&