我有一个 MyClass 的实例,定义为:
public partial class MyClass
{
public virtual string PropertyName1 { get; set; }
public virtual IList<Class2List> Class2Lists{ get; set; }
}
我使用反射来尝试找到Remove
方法:
object obj1 = myClassObject;
Type type = obj1.GetType();
Type typeSub = type.GetProperty("Class2Lists").PropertyType;
//this method can not find
MethodInfo methodRemove = typeSub.GetMethod("Remove");
// this method can find
MethodInfo methodRemove = typeSub.GetMethod("RemoveAt");
// there is no "Remove" method in the list
MethodInfo[] methodRemove = typeSub.GetMethods();
但是我找不到Remove
方法,为什么?