Assume I have a class C
that inherits from 2 interfaces (I1
and I2
). I also have two versions of a method (DoStuff
), each taking one of the interfaces as a parameter. If I call DoStuff(C)
, which one gets called?
interface I1 { ... }
interface I2 { ... }
class C : I1, I2 { ... }
int DoStuff(I1 target) { ... }
int DoStuff(I2 target) { ... }
//What gets called here?
C target = new C()
DoStuff(target)
If I2
derives from I1
, I think it's relatively simple - the I2
version gets called. I'm interested in the case where the interfaces are independent.
Assume I can't edit C
, I1
or I2
. And .NET 2.0 if that makes any difference.