I have two interfaces with methods having same names and parameters. In a class, i implements these two interfaces. How can i call it?
Keyur Patel
For Example, If you are having two interfaces are named as,public interface IA { void XYZ(); }public interface IB { void XYZ(); }And you can implement these two interfaces in a class as below,public class C1 { public void IA.XYZ() { //something IA }public void IB.XYZ() { //something IB } }Now you can call these methods as below,IA obj1 = new C1(); IB obj2 = new C1();obj1.XYZ(); // calls the method of interface IAobj2.XYZ(); // calls the method of interface IB
1. implement methods with filly qualified name e.g. I1.GetdEscription() where I1 is the interface2. You need to explicitly cast your call instance to the interface you want to call and call the method