Implementing two methods with same name from two different interfaces
Implementing two methods with same name from two different interfaces
If we have to implement a method of same name in two different interfaces,then we need to do it in slight different way:
interface I2
{
void print();
}
interface I1
{
void print();
}
}
Implementation in a class:
void I1.print()
{
Console.WriteLine("This is print method of Interface I1");
}
void I2.print()
{
Console.WriteLine("This is print method of Interface I2");
}
And call it like
ClassChild obj = new ClassChild();
I1 objI1 = (I1)obj;
objI1.print();
I2 objI2 = (I2)obj;
objI2.print();
Some details needed, although this will help to understand on implementing two methods with same name from two different interfaces!