为什么我们在接口中不使用私有或受保护的访问修饰符 [英] Why we wont use private or protected access modifier in Interface

查看:90
本文介绍了为什么我们在接口中不使用私有或受保护的访问修饰符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi ,

 As we know Interface in C#. Its accessmodifier is Public by default. My question is why we wont use private or protected as access modifier in Interface. Please reply me with example.

推荐答案

因为,粗略地说,接口抽象了实际实现,而privateprotected访问修饰符通常与实现完全相关.
该接口是合同,因此必须完全可访问.
Because, roughly speaking, an interface abstracts the actual implementation, while private and protected access modifiers typically pertain the very implementation.
The interface is a contract, hence it has to be fully accessible.


这篇关于为什么我们在接口中不使用私有或受保护的访问修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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