OO:接口可以实现另一个接口吗?

2 architecture oop user-interface

我知道它是特定于语言的,但是在OO语言中,接口可以实现其他接口吗?

Sim*_*one 5

在C#中你可以这样做:

interface YourInterface: IDisposable {
   /// your methods
}
Run Code Online (Sandbox Code Playgroud)

一个实现的类YourInterface也应该实现IDisposable方法.

当然,这是有效的:

YourInterface implementation = new Implementation();
IDiposable disposable = implementation;
Run Code Online (Sandbox Code Playgroud)


Clo*_*ble 5

接口可以扩展但不实现另一个接口,因为接口中没有实现.