- Where Developers Learn, Share, & Build Careers
How do I get my property? Currently a code ... Derivative types declare a property that hides a successive property with the same name, using the new modifier If you run the following You will notice that the two You can get to has got a suspicious match , see the comment row in the code.
Public category MyBaseEntity {public MyBaseEntity MyEntity {get; Set; }} Public category MyDerivedEntity: MyBaseEntity {public New MyDerivedEntity MyEntity {get; Set; }} Private Static Zero Main (string [] Args) {MyDerivedEntity myDE = New MyDerivedEntity (); PropertyInfoPenFofofostown = myDE.GetType (). GetProperty ("MyEntity"); // - Error: Unmatched matching found}
< P> Such situations in which ambiguity arises ...
var properties = myDE.GetType (). GetProperties (). Where (P = & gt; p.Name == "MyEntity");
PropertyInfo objects are returned. One is for
MyBaseEntity another
MyDerivedEntity . This is the reason that you are receiving suspicious match error.
MyDerivedEntity for
PropertyInfo this way:
propertyfile propinfoSrcObj = myDE .GetType () GetProperties (). Single (P = & gt; P. Name == "Myintitude" & amp; amp; amp; amp; amp; P. Property Type == Type (MyDerivedEntity);
Comments
Post a Comment