In layman's terms, if a class inherits from 2 or more interfaces, and if the interfaces have the same method names, the class does not know which interface method is implemented if you use an implicit interface implementation. This is one of the scenarios when you explicitly implement the interface.
Implicit Interface Implementation
public class MyClass : InterfaceOne, InterfaceTwo { public void InterfaceMethod() { Console.WriteLine("Which interface method is this?"); } } interface InterfaceOne { void InterfaceMethod(); } interface InterfaceTwo { void InterfaceMethod(); }
Explicit interface implementation
public class MyClass : InterfaceOne, InterfaceTwo { void InterfaceOne.InterfaceMethod() { Console.WriteLine("Which interface method is this?"); } void InterfaceTwo.InterfaceMethod() { Console.WriteLine("Which interface method is this?"); } } interface InterfaceOne { void InterfaceMethod(); } interface InterfaceTwo { void InterfaceMethod(); }
The following link has a great video explaining this concept
Explicit interface implementation
Suresh Sep 21 '12 at 12:35 2012-09-21 12:35
source share