0
我试图使用反射出于某种原因,我陷入了这个问题。c#反射问题
class Service
{
public int ID {get; set;}
.
.
.
}
class CustomService
{
public Service srv {get; set;}
.
.
.
}
//main code
Type type = Type.GetType(typeof(CustomService).ToString());
PropertyInfo pinf = type.GetProperty("Service.ID"); // returns null
我的问题是,我想获得一个propery里面的主要对象的另一个属性。 有没有一个简单的方法来实现这个目标?
在此先感谢。
为什么Type.GetType(typeof(CustomService).ToString())而不是typeof(CustomService)? –