如何獲取我的財產?目前出現Ambiguous match found
錯誤,請參閱代碼中的註釋行。GetProperty反射結果在新屬性中發現「模糊匹配」
public class MyBaseEntity
{
public MyBaseEntity MyEntity { get; set; }
}
public class MyDerivedEntity : MyBaseEntity
{
public new MyDerivedEntity MyEntity { get; set; }
}
private static void Main(string[] args)
{
MyDerivedEntity myDE = new MyDerivedEntity();
PropertyInfo propInfoSrcObj = myDE.GetType().GetProperty("MyEntity");
//-- ERROR: Ambiguous match found
}
運行時錯誤或編譯時錯誤? – 2012-07-12 01:07:08
@Valamas請重新考慮選定的答案。許多人會在這裏使用像if(winform.GetType()。GetProperty(「Items」)!= null){..}這樣的條件結構,在這種情況下,僅僅使用Linq來切換異常...... – 2013-09-27 21:01:01