using System;
interface one
{
void getdata();
}
interface two : one
{
new void getdata();
void showdata();
}
class intefacehierarchy:two,one
{
string name;
public void getdata()
{
Console.WriteLine("ok tell me your name");
}
public void getdata()
{
Console.WriteLine("Enter the name");
name = Console.ReadLine();
}
public void showdata()
{
Console.WriteLine(String.Format("hello mr. {0}", name));
}
}
答案 0 :(得分:3)
好的,这只是猜测,因为你没有真正提出问题,但你可以使用显式接口实现:
class intefacehierarchy:two,one
{
string name;
// implements two.getdata
public void getdata()
{
Console.WriteLine("ok tell me your name");
}
// implements one.getdata explicitly
void one.getdata()
{
Console.WriteLine("Enter the name");
name = Console.ReadLine();
}
// implements two.showdata
public void showdata()
{
Console.WriteLine(String.Format("hello mr. {0}", name));
}
}