Monday 5 November 2012

Program to illustrate the use of explicit interface implementation


using System;
interface I1
{
 void Display();
}
interface I2
{
 void Display();
}
class C : I1 , I2
{
 void I1.Display()
 {
  Console.WriteLine("I1 Display Method called .");
 }
 void I2.Display()
 {
  Console.WriteLine("I2 Display Method called .");
 }
}
class InterfaceTest
{
 static void Main()
 {
  C c = new C();
  I1 i1 = c as I1;
  i1.Display();
  I2 i2 = (I2)c;
  i2.Display();
  Console.ReadKey();
 }
}

Output:-

No comments:

Post a Comment