A class called One which inherits two interface i1 & i2. I1 has a method called method1(). I2 has a method called method1(). These two interface I1 & I2 have same method name called method1(). in it.
the class One implements the method method1() by interface name with dot and method name like
interface.method1()
again we come to access part of those method in derived class called two. create the object for base class and assign it to interface declaration. call method by using interface
The real example below
class Program
{
static void Main(string[] args)
{
two obj = new two();
obj.method2();
Console.ReadLine();
}
}
interface i1
{
void method1();
}
interface i2
{
void method1();
}
class one : i1, i2
{
void i1.method1()
{
Console.WriteLine("test i1");
}
void i2.method1()
{
Console.WriteLine("test i2");
}
}
class two : one
{
internal void method2()
{
i1 obji1 = new one();
obji1.method1();
i2 obji2 = new one();
obji2.method1();
}
}
Thanks
gunasekaran
No comments:
Post a Comment