How to do proper Reflection of base Interface methods

后端 未结 3 1603
耶瑟儿~
耶瑟儿~ 2020-12-18 21:33

I have 2 interfaces and 2 classes that I investigate via Reflection:

  • IParent
  • IChild - derives from IParent
  • Parent
  • Child - derives f
3条回答
  •  爱一瞬间的悲伤
    2020-12-18 22:26

    If you are dealing with an interface, use

    t.GetInterfaces()
    

    then you can check for methods on the types returned above.

    Finding interface members by name is not relyable, be mindful that whilst in C# interface members cannot be renamed on implementation, in the CLR the names may be modified. (IDisposable.Dispose() is sometimes renamed to Close). In il there is an instruction called .implements that allows one to change names. I believe VB.Net also has this feature.

提交回复
热议问题