受保护的关键字 C# [英] Protected Keyword C#

查看:61
本文介绍了受保护的关键字 C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道C#中protected是什么意思,我们为什么要使用它,以及关键字的好处?

I want to know what is the meaning of protected in C#, why we use it, and the benefit of the keyword?

例如

protected int currentColorIndex;

请详细说明.

推荐答案

"受保护的成员可以从在它所在的班级内声明,并从任何类中派生自声明的类这个成员."

"A protected member is accessible from within the class in which it is declared, and from within any class derived from the class that declared this member."

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/protected

这篇关于受保护的关键字 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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