反射学习.

1.GetType() :

  XXXObject object;

   Object.GetType(); 不管XXXObject是那一级别,GetType始终返回最末一级的类型.

2.GetMeath():返回基类,子类的所有方法.

 

代码
                MethodInfo beforeCopy = newObject.GetType().GetMethod("BeforeCopy");
                
if (beforeCopy != null)
                {
                    beforeCopy.Invoke(newObject, 
null);
                }

 

 3.GetProperty

 


            var property 
= obj.GetType().GetProperty(propertyName);            
            
return property.GetValue(obj, null);

 

 

posted @ 2010-04-26 12:01  SouthAurora  Views(154)  Comments(0Edit  收藏  举报