Get derived class type from a base's class static method

前端 未结 8 991
走了就别回头了
走了就别回头了 2020-12-01 14:44

i would like to get the type of the derived class from a static method of its base class.

How can this be accomplished?

Thanks!

class BaseCla         


        
8条回答
  •  半阙折子戏
    2020-12-01 15:05

    Why not just use the methods that are there already?

    If you have

    class BaseClass {}
    partial class DerivedClass : BaseClass {}
    

    You can look at

    DerivedClass.GetType().BaseType;
    

提交回复
热议问题