类继承,扩展和实现oop之间的区别 [英] Difference between Class Inherit, extend and implement oops
问题描述
我知道这是一个愚蠢的问题,但仍然想清楚地知道. 两者之间的适当区别 继承课程, 扩展课程, 实施课程
I know this is a stupid question, but still want to know it clearly. The proper difference between Inheriting a class, extending a class, Implementing a class
请举例说明.
如果您可以提供给我有关C#的完整详细信息的资料,供您学习. 预先感谢.
And if you can provide me a source for a complete detailed oops in c# for studying. Thanks in advance.
推荐答案
要弄清Feisty Mango的评论,
To clarify what Feisty Mango commented:
Inheriting
指的是派生类(子级)和基类(父级)之间的关系.派生类可以根据可访问性级别在基类中使用某些方法和字段(有关此内容的更多信息,请此处)
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
与Inheriting
可以互换,通常在Java中使用(因为Java中继承的语法是关键字extends
.在C#中,它是冒号:
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
通常与接口而不是类一起使用.主要是因为inheriting
或extending
表示正在使用部分类,而对于implementing
,则意味着整个接口都必须由实现它的人来定义.
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.
要记住的另一件事是,在C#中,您只能extend
或inherit
一个类,但是可以实现多个接口!
Another thing to keep in mind is that you can only extend
or inherit
one class in C#, but can implement multiple interfaces!
MSDN 在其他地方提供了与继承相关的良好信息
MSDN provides good information related to inheritance, among other places
这篇关于类继承,扩展和实现oop之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!