【发布时间】:2010-11-03 14:44:47
【问题描述】:
为什么在实现接口时,如果我将方法设为公开,我不必显式指定接口,但如果我将其设为私有,我必须...喜欢这样(GetQueryString 是来自 IBar 的方法):
public class Foo : IBar
{
//This doesn't compile
string GetQueryString()
{
///...
}
//But this does:
string IBar.GetQueryString()
{
///...
}
}
那么为什么在方法设为私有时必须显式指定接口,而在方法设为公开时却不需要呢?
【问题讨论】:
-
当您说不起作用时,您的意思是 - 无法编译或无法按预期运行?
标签: c# interface access-modifiers