Prakash Tripathi

Prakash Tripathi

  • 25
  • 43.8k
  • 6.2m

Interface implementation in C#

Oct 12 2014 5:39 AM

Hi guys,

Can someone tell me why I am getting  output as  I am from I1 in both the cases explained below.

 interface I1

{

void Cal1();

}

interface I2

{

void Cal1();

}

class Program: I1,I2

{

void I1.Cal1()

{

Console.WriteLine("I am from I1");

}

void I2.Cal1()

{

Console.WriteLine("I am from I2");

}

static void Main(string[] args)

{

I1 i1 = new Program();

i1.Cal1(); //Actual output: I am from I1

I1 i2 = new Program();

i2.Cal1();  //Actual output: I am from I1, Expecting I am from I2

 
Thanks,
Prakash 

Answers (3)