Is there a reason you can not define the access modifier on a method or in an interface?

access-modifiers, c#, interface

Solution

The interface defines a contract between an object and clients that call its members. A private method cannot be accessed by any other objects so it doesn't make sense to add it to the interface. All members of an interface are considered public for this reason.

Problem

The responsibility of the visibility of a method is relegated to the class that implements the interface. ``` public interface IMyInterface { bool GetMyInfo(string request); } ``` In C# set access modifier public, private or protected before the method GetMyInfo() generates the following error: The modifier 'private' is not valid for this item. Is there a reason you can not define the access modifier on a method or in an interface? (Question already asked in french here)

Original source