Let’s Assume we have two interface with same contract:
interface ITest { void Test(); //Same Contract as of other interface } interface ITest1 { void Test(); //Same Contract as of other interface }
To define both the Interface with same contract in a class,you have to define Interface Explicitly without Access Modifier.
class Sample:ITest,ITest1 { void ITest.Test() { Console.WriteLine("Hello"); } void ITest1.Test() { Console.WriteLine("Hello1"); } }
To invoke the specific Contract,
//You cannot invoke Explicit Interface with Class Instance. ITest s1 = new Sample(); s1.Test(); ITest1 s2 = new Sample(); s2.Test();