Interviews4 answers
How can we implement the two interfaces having same method names ?
4 Answers
Interface Interface1
{
void Add();
}
interface Interface2
{
void Add();
}
public class Baseclass :interface1,Interface2
{
Interface.Add()
{
console.Writeline();
}
Interface.Add()
{
Console.writeline();
}
Public Static Void Main()
{
baseclass b=new baseclass();
interface1 f1=b;
b.add();
interface2 f2=b;
b.add();
}
}
pardhu utlapalliPosted Jun 23, 2015, 12:15 AM EDT
i am agree with dillip
Sneha PandaPosted Dec 15, 2014, 8:23 AM EST
Refer this link:
http://msdn.microsoft.com/en-us/library/ms173157.aspx
Prakash LakshmananPosted Dec 14, 2014, 11:55 PM EST
yes,By explicit interface implementation
Example:
protected void Page_Load(object sender, EventArgs e)
{
I1 obj1 = new A();
I2 obj2 = new A();
lblResult1.Text = obj1.Interview();
lblResult2.Text = obj2.Interview();
}
interface I1
{
string Interview();
}
interface I2
{
string Interview();
}
class A : I1, I2
{
string I1.Interview()
{
return "Result2";
}
string I2.Interview()
{
return "Result";
}
}
Dillip NayakPosted Oct 15, 2014, 1:12 PM EDT


