how to distinguish methods [closed]
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));
}
}
OK, that's just a guess since you didn't really ask a question, but you can use explicit interface implementation:
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));
}
}
精彩评论