Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Implementing multiple interfaces can sometimes result in a collision between member signatures. You can resolve such collisions by explicitly implementing an interface member. For example:
interface I1 { void Foo(); }
interface I2 { int Foo(); }
public class Widget : I1, I2
{
public void Foo() // Implicit implementation
{
Console.Write ("Widget's implementation of I1.Foo");
}
int I2.Foo() // Explicit implementation of I2.Foo
{
Console.Write ("Widget's implementation of I2.Foo");
return 42;
}
}
Because both I1 and I2 have conflicting Foo signatures, Widget explicitly implements I2’s Foo
method. This lets the two methods coexist in one class. The only way to
call an explicitly implemented member is to cast to its
interface: