【发布时间】:2011-09-22 10:26:41
【问题描述】:
我有代码
internal interface IFoo
{
void foo();
}
public class A : IFoo
{
// error CS0737: 'A' does not implement interface member 'IFoo.foo()'.
//'A.foo()' cannot implement an interface member because it is not public.
internal void foo()
{
Console.WriteLine("A");
}
}
为什么会有这种奇怪的限制?我有内部接口,为什么我不能在接口实现中创建内部方法?
【问题讨论】:
-
你不能有一个暴露在外面的公共类,实现一个不会暴露的内部接口。没有意义。
-
你有没有尝试显式地实现接口:void IFoo.foo() { /* stuff */ }