如何获取我的属性?目前出现了Ambiguous match found
的错误,请参见代码中的注释行。
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
}
if (winform.GetType().GetProperty("Items") != null) {..}
在这种情况下,只需使用Linq切换异常... - Lorenz Lo Sauer