Scenario:-
Interface polymorphism with multiple interfaces having same method.
public interface MyInterface1
{
int foo();
}
public interface MyInterface2
{
int foo();
}
public class MyClass : MyInterface1, MyInterface2
{
int a = 10;
#region MyInterface1 Members
public int foo()
{
return a;
}
#endregion
}
MyClass obj = new MyClass();
MyInterface1 obj2 = (MyInterface1)obj;
MyInterface2 obj3 = (MyInterface2)obj;
obj.foo(); //Returns 10
obj2.foo(); //Returns 10
obj3.foo(); //Returns 10