C# : how do you obtain a class' base class?

前端 未结 7 1668
面向向阳花
面向向阳花 2021-02-05 00:36

In C#, how does one obtain a reference to the base class of a given class?

For example, suppose you have a certain class, MyClass, and you want to obtain a

7条回答
  •  生来不讨喜
    2021-02-05 01:28

    if you want to check if a class is subclass of another you can use is.

    if (variable is superclass){ //do stuff }
    

    Docs: https://msdn.microsoft.com/en-us/library/scekt9xw.aspx

提交回复
热议问题