c# - 当一个接口(interface)从另一个接口(interface) "inherits"时,你怎么调用它?

标签 c# oop interface

如果我有 B 类:A {}

我说“B 类 继承 A 类”或“B 类派生自 A 类”。

但是,如果我有:

  class B : ISomeInterface   {}

说“B 继承了 ISomeInterface”是错误的——正确的说法是“B 实现 ISomeInterface”。

但是,假设我有

  interface ISomeInterface : ISomeOtherInterface   {}

现在,说“继承”仍然是错误的,但现在说“实现”也是错误的,因为 ISomeInterface 没有实现任何东西。

那么,您如何称呼这种关系?

最佳答案

我个人说“扩展”,我认为 C# 规范也在某处使用了这个词(不幸的是,我现在找不到它)——但我记得 Eric Lippert 说他不是热衷于它,并希望将其更改为 4.0。

我认为这很好,因为它表明您正在扩展原始接口(interface)指定的契约(Contract)。

编辑:看过 3.0 规范...

规范回避了第 13.2 节中的问题。它讨论了从基本接口(interface)继承的成员。它谈论一个扩展另一个,但不是接口(interface)

编辑:在 C# 5 规范的第 13.1.4 节中,它使用继承:

An interface can inherit from zero or more interface types

所以这可能是最好的术语。

关于c# - 当一个接口(interface)从另一个接口(interface) "inherits"时,你怎么调用它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/807217/

相关文章:

c# - 使用 C# SDK 投影到另一种类型

C# 使用子级 "base"调用尊重的类特定成员引用

java - 使用(空)默认方法制作 FunctionalInterface

具有数据绑定(bind)的 C# 文本框未更新

c# - 带有内部连接的 SQL Server NULL 值

c# - 多字符串替换性能

java - 允许单位使用设计模式在 Java 中攻击地面、空中或两者的能力的接口(interface)

c++ - 对象修改是否创建新对象?

python - Python 中的通用类工厂

python - DBus 接口(interface)属性