When you implement two interfaces with the same method, how do you know which one is called?

后端 未结 8 1372
再見小時候
再見小時候 2021-01-13 05:18

If you have TheMethod() in interfaces I1 and I2, and the following class

class TheClass : I1, I2
{
    void TheMethod()
}

If s

8条回答
  •  不思量自难忘°
    2021-01-13 05:41

    As long as the method signatures are the same, it is perfectly legal for a method to implement the methods of two or more interfaces.

    There is no way to know "through which interface" a method is called -- there is no such concept (and it doesn't matter).

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题