接口成员为何没有访问修饰符? [英] Why do interface members have no access modifier?

查看:320
本文介绍了接口成员为何没有访问修饰符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
我为什么不能有保护的接口成员?

为题,在C#。有没有可能有人会希望有一个保护的或内部接口?

as title, in C#. Is there no possibility that someone might want to have a protected or an internal interface?

推荐答案

由于接口是原油条款一视图向外界'和,因为它是对外界,没有一点使得其成员保护或私有

Because Interface is in crude terms 'a view to the outside world' and since it is for the outside world, there is no point making its members protected or private.

或者换言之,它是一个< STRONG>合同与外部世界的,它指定类实现这个接口做了一定的一套东西。因此,隐藏它的某些部分没有意义。

Or in other words, it is a contract with the outside world which specifies that class implementing this interface does a certain set of things. So, hiding some part of it doesn't make sense.

但是,接口本身可以访问修饰符如保护内部等。因此限制了外面的世界到整个外部世界的一个子集。

However, interfaces themselves can have access specifiers like protected or internal etc. Thus limiting 'the outside world' to a subset of 'the whole outside world'.

这篇关于接口成员为何没有访问修饰符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆