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();


Comments

Author: Zahid Sikder16 Sep 2010 Member Level: Bronze   Points : 1

Some details needed, although this will help to understand on implementing two methods with same name from two different interfaces!



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: