using System;
namespace ConsoleApplication16
{
public interface A
{
void Hello();
}
public interface B
{
void Hellonew();
}
// Interface C inherite interface A and B
// C is a interface so can not define the function of interface A and B function inherted
// Program class we do implementation
public interface C : A , B
{
void HelloOld();
}
public class Program : C
{
void A.Hello() // this is the way to implement a function to reduce ambiguity bacuse may be other interface may have same function name
{
Console.WriteLine("Interface A is Called");
}
void B.Hellonew() // same as Interface A
{
Console.WriteLine("Interface B is Called");
}
void C.HelloOld() // same as Interface A
{
Console.WriteLine("Interface C is Called");
}
}
class derived : Program
{
static void Main(string[] args)
{
derived obj = new derived(); // this is the way to call interface function by derived class from Program class
((C)obj).Hello();
((C)obj).Hellonew();
((C)obj).HelloOld();
C objnew = new Program(); // this is the way to call interface function by Program class
objnew.Hello();
objnew.Hellonew() ;
objnew.HelloOld();
Console.ReadKey();
}
}
}Output would be same:
// Interface A is Called
// Interface B is Called
// Interface C is Called
// Interface A is Called
// Interface B is Called
// Interface C is Called
