Quote:
Originally Posted by philip_cole
They both are! Because interfaces just say what the method signature (name+parameters+return type) should look like, without any actual logic, it doesn't really matter which one is "executed". The important bit is that A.get() is run.
If one interface returned something different to the other, there is obviously more of a need to know which one to use. As this is impossible to work out however, the code would not compile.
HTH
Phil
|
Sorry, but this is technically incorrect.. It's not a case of they "both are", rather the ones that satisfy the interface are run.
e.g.
Implicit implementation
public string Get () { ... }
Explicit implementation
string InterfaceA.Get() { ... }
string InterfaceB.Get() { ... }
If implicit, there is only one method to call.
If explicit, then it will call the appropriate type
e.g. InterfaceA mc = new MyClass()
.. Will call the explicit InterfaceA.Get - which can be very different to InterfaceB..
Sorry to split hairs on this, but I think it is important to be clear on the actual behaviour, this kinda stuff can really slip people up! :)
In short