你怎么称呼它,当一个接口"继承"从另一个? [英] What do you call it when one interface "inherits" from another?

查看:158
本文介绍了你怎么称呼它,当一个接口"继承"从另一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有
B类:A {}

If I have class B : A {}

我说,B级的继承的A级或

I say that "Class B inherited class A" or "class B derives from class A".

However, if I instead have:

不过,如果我不是有C $ C> b类:ISomeInterface {}

class B : ISomeInterface {}

这是错误的说法b继承ISomeInterface - 适当的期限是说b的工具的ISomeInterface。

it's wrong to say "B inherits ISomeInterface" -- the proper term is to say "B implements ISomeInterface".

不过,说我有

  interface ISomeInterface : ISomeOtherInterface   {}

现在,它仍然是错误的说法继承,但它现在只是因为错误的说工具,因为ISomeInterface没有实现任何东西。

Now, it's still wrong to say "inherits", but it's now just as wrong to say "implements" since ISomeInterface doesn't implement anything.

那么,你叫什么了关系?

So, what do you call that relationship?

推荐答案

我个人说:伸出我的认为的C#的规范使用这个词作为还有的地方(我现在不能找到它,可惜) - 但我记得埃里克利珀说他并不热衷于它,并想改变它的4.0

I personally say "extends" and I thought the C# spec uses that word as well somewhere (I can't find it now, unfortunately) - but I remember Eric Lippert saying he wasn't keen on it, and wanted to change it for 4.0.

我认为这是很好的,因为它表明你是通过延长原有接口指定的合约

I think it's good, because it shows that you're extending the contract specified by the original interface.

编辑:说完看了看3.0规范...

Having looked at the 3.0 spec...

该规范排序在第13.2侧步的问题。它谈论的成员正在从基接口继承。它谈论有一个的另一种延伸,而不是接口

The spec sort of side-steps the issue in section 13.2. It talks about the members being inherited from the base interfaces. It talks about one class extending another, but not interfaces

编辑:在C#5规范,13.1.4节,它采用继承:

In the C# 5 spec, section 13.1.4, it uses inherits:

这是接口可以从零个或多个接口类型继承

An interface can inherit from zero or more interface types

所以,这可能是使用最好的词。

So that's probably the best term to use.

这篇关于你怎么称呼它,当一个接口"继承"从另一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆