1.GetType() :
XXXObject object;
Object.GetType(); 不管XXXObject是那一级别,GetType始终返回最末一级的类型.
2.GetMeath():返回基类,子类的所有方法.
代码
MethodInfo beforeCopy = newObject.GetType().GetMethod("BeforeCopy");
if (beforeCopy != null)
{
beforeCopy.Invoke(newObject, null);
}
if (beforeCopy != null)
{
beforeCopy.Invoke(newObject, null);
}
3.GetProperty
var property = obj.GetType().GetProperty(propertyName);
return property.GetValue(obj, null);