Answer the question
In order to leave comments, you need to log in
Why is there such a strange restriction on the implementation of the internal interface in C#?
internal interface IFoo
{
void foo();
}
public class Foo : IFoo
{
internal void foo()
{
throw new NotImplementedException();
}
}
Program.cs(8,14): error CS0737: 'Foo' does not implement interface member 'IFoo.foo()'. 'Foo.foo()' cannot implement an interface member because it is not public.
Answer the question
In order to leave comments, you need to log in
Because interface, by definition, only contains descriptions of public members.
Use an explicit interface method implementation:
void IFoo.foo()
{
throw new NotImplementedException();
}
Foo obj = new Foo();
((IFoo)obj).foo();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question