为什么默认情况下接口方法是公共的? [英] Why Interface methods are public by default ?

查看:62
本文介绍了为什么默认情况下接口方法是公共的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么默认情况下接口方法是公共的?
为什么我们不能在接口中有一个受保护的方法?

Why Interface methods are public by default ?
Why cant we have a protected method in interface ?

推荐答案

接口旨在为继承该类的类提供一个与外界一致的已知接口".定义带有私有方法的接口将毫无意义.

阅读 MSDN文档,以更好地理解为什么会出现这种情况.
An interface is designed to provide a known and consistent "interface" to the outside world for classes that inherit it. There would be little point in having an interface with private methods defined.

Read up on the MSDN Documentation to understand better why this is the case.


这篇关于为什么默认情况下接口方法是公共的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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