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

后端 未结 5 1998
悲哀的现实
悲哀的现实 2020-12-21 00:23

The responsibility of the visibility of a method is relegated to the class that implements the interface.

public interface IMyInterface
{
  bool GetMyInfo(st         


        
5条回答
  •  旧时难觅i
    2020-12-21 00:55

    All of the methods of an interface must have the same access level - so that the caller may use all of them. However interfaces can also be internal (or as nested interface private).

    If you need different access levels use a distinct interface.

提交回复
热议问题