Difference between Class Inherit, extend and implement oops

前端 未结 1 1310
说谎
说谎 2021-02-07 11:41

I know this is a stupid question, but still want to know it clearly. The proper difference between Inheriting a class, extending a class,

相关标签:
1条回答
  • 2021-02-07 12:04

    To clarify what Feisty Mango commented:

    Inheriting refers to the relationship between a derived class (the child) and the base class (the parent). The derived class can use certain methods and fields within the base class according to accessibility levels (more about that here)

    Extending is interchangeable with Inheriting and usually is used in java (since the syntax for inheritance in java is the keyword extends. In C#, it is colon :

    Implementing usually is used with interfaces instead of classes. Mainly because inheriting or extending implies parts of classes are being consumed, where with implementing, it implies the entire interface must be defined by whoever implements it.

    Another thing to keep in mind is that you can only extend or inherit one class in C#, but can implement multiple interfaces!

    MSDN provides good information related to inheritance, among other places

    0 讨论(0)
提交回复
热议问题