That's not accurate.
Anything in an interface is public, even if the interface itself is internal, so you can't set any access modifier to any member of an interface.
In a class implementing an interface, any member (property, method, event or indexer) that explicitly implement the interface is public and you can't set any access modifier to it as well.
But any member that implicitly implements the interface you must specify an access modifier.
Since everything in an interface is public, and you can't overload methods based on their access modifiers, Any other modifier will generate a compilation error.
Why does the compiler forces you to declare implicit interface implementation members as public?
Well, I'm not sure about the reason, but I assume that's because the default access modifier for class members is private
, and allowing programmers to implicitly implement interfaces without specifying the public
access modifier would mean that the c# compiler team must put in some extra work to make that happen, and (I think) more importantly, has a potential to confuse any developer looking at the code, Given that the implementation is implicit and without knowing the interface you can't know if a method in the class is an implementation of the interface or just a regular method.