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)? –