Why can't I have protected interface members?

后端 未结 13 1895
走了就别回头了
走了就别回头了 2020-11-29 19:58

What is the argument against declaring protected-access members on interfaces? This, for example, is invalid:

public interface IOrange
{
    public OrangePee         


        
13条回答
  •  春和景丽
    2020-11-29 20:30

    Because it makes no sense. An interface is a publicly exposed contract. I am an IThing, therefore I will perform IThing methods if asked. You can't ask an IThing to confirm it performs methods it can't tell you about.

提交回复
热议问题