How does reflection tell me when a property is hiding an inherited member with the 'new' keyword?

后端 未结 4 749
时光说笑
时光说笑 2020-12-15 18:07

So if I have:

public class ChildClass : BaseClass
{
    public new virtual string TempProperty { get; set; }
}

public class BaseClass
{
    public virtual s         


        
4条回答
  •  被撕碎了的回忆
    2020-12-15 18:55

    I never did what you are trying to do but MethodInfo.GetBaseDefinition() method seems to be what you are looking for.

    It returns the MethodInfo this method is overriding.

    From MSDN :

    If a given method is specified with the new keyword (as in newslot as described in Type Members), the given method is returned.

提交回复
热议问题