This code compiles without an error
class program
{
interface IA
{
void getName(string s);
}
interface IB
{
void getName(string s);
}
interface IC
{
void getName(string s);
}
public abstract class AC
{
public abstract void getName(string s);
}
public class CA : AC , IA, IB, IC
{
public override void getName(string s)
{
Console.WriteLine(s);
}
}
static void Main()
{
CA ca = new CA();
Console.ReadLine();
}
}
Which getName method is implemented? If we have a multiple interfaces with the same method name, is it enough to implement just one method that would satisfy all the interfaces? What if they do different things? Notice that I didn't specify which getName there is (unlike the solution at this explicit naming).
Thanks all.
overridethen the compiler complains about thegetNamein abstract method is not not implemented. So it appears to be a one-way thing.overridemodifier.