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


VulpesRank #55 · 29.2K reputationPosted Oct 12, 2014, 4:55 AM EDT
I2 i2 = new Program();
i2.Call();
Munesh SharmaRank #174 · 13.9K reputationPosted Oct 12, 2014, 8:32 PM EDT
http://csharp.net-tutorials.com/classes/interfaces/
Prakash TripathiRank #72 · 25.3K reputationPosted Oct 15, 2014, 8:08 PM EDT