top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What happens if the inherited interfaces have conflicting method names?

0 votes
317 views
What happens if the inherited interfaces have conflicting method names?
posted Mar 31, 2017 by Rohini Agarwal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

If we implement multipole interface in the same class with conflict method name so we don’t need to define all or in other words we can say if we have conflict methods in same class so we can’t implement their body independently in the same class because of same name and same signature so we have to use interface name before method name to remove this method confiscation let’s see an example:

interface testInterface1

{
void Show();
}
interface testInterface2
{
void Show();
}

class Abc: testInterface1, testInterface2

{
void testInterface1.Show()
{
Console.WriteLine("For testInterface1 !!");
}
void testInterface2.Show()
{
Console.WriteLine("For testInterface2 !!");
}
}

 class Program {
 static void Main(string[] args) {
 testInterface1 obj1 = new Abc();
 testInterface1 obj2 = new Abc();
 obj1.Show();
 obj2.Show();
 Console.ReadLine(); } }
answer Mar 31, 2017 by Shweta Singh
Similar Questions
+1 vote

I am trying to get all the collection names from MongoDb server using C# code using db.GetCollectionNames() method.

I have 12 collections in my database, but the above method returns an empty list. I have verified that I am referring to the correct database. What am I doing wrong? Or if there is an alternate way?

...