3
为什么在实现接口时,如果我公开该方法,则不必明确指定接口,但如果我将其设为私有,则必须...像这样的(GetQueryString
是伊巴尔的方法):C#:在实现的方法中明确指定接口
public class Foo : IBar
{
//This doesn't compile
string GetQueryString()
{
///...
}
//But this does:
string IBar.GetQueryString()
{
///...
}
}
那么,为什么你必须明确地,当该方法是由私人指定接口,而不是当该方法是公开的?
当你说不起作用,你的意思是 - 不编译或不按预期运行? – 2009-06-17 09:57:46
不能编译 – 2009-06-17 10:05:19