开发者

how to distinguish methods [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, over开发者_如何转开发ly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.
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));

    }

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜