我们可以在c#中实现两个具有相同功能的接口吗?
interface TestInterface
{
public function testMethod();
}
interface TestInterface2
{
public function testMethod();
}
class TestClass implements TestInterface, TestInterface2
{
}
Run Code Online (Sandbox Code Playgroud)
这可能吗?
我发现这里的 PHP不可能
是的,您可以使用接口名称限定方法名称:
class TestClass : TestInterface, TestInterface2
{
void TestInterface.testMethod()
{
}
void TestInterface2.testMethod()
{
}
}
Run Code Online (Sandbox Code Playgroud)
虽然我不建议有这样的结构 - 它应该只是为了学术兴趣:-)
| 归档时间: |
|
| 查看次数: |
146 次 |
| 最近记录: |