Cisco CloudCenter: Get the Hybrid IT Advantage


Definition - What does Protected mean?

Protected, in C#, is a keyword used to declare the accessibility of a class member such that access to that member is limited to the containing class in which it is declared or to any class derived from the containing class. Protected accessibility can be used in field, method and property declarations to prevent them from being fully visible outside of their class.

Protected is an access modifier that enables the member of a class to be more visible than private but less than public accessibility. The protected members of a base class can be shared only by their descendants, which can override or use them.

Protected modifier helps to implement the concept of encapsulation in C# object-oriented programming. It is mainly used with members of a base class that are re-used in the derived class, which helps to provide centralization of common logic along with rich class hierarchy.

Techopedia explains Protected

A protected member can be accessible in the derived class only if the access takes place through the derived class. If it needs to be accessed from outside the program text of the class in which it is declared, it should be through an instance of derived type or a class type constructed from it.

For example, BankAccount class represents the account details of a user and can define a method, CalculateInterest, as protected so that any class derived from BankAccount class (such as SavingsAccount, CheckingAccount, etc.) can override the CalculateInterest method with the code necessary to calculate interest based on the type of account.

A protected member cannot be used with a static modifier because it can be accessed only through an instance. A protected modifier cannot be used with members of a struct because inheritance is not supported by struct.

A protected method can be declared with the "virtual" modifier to extend the logic that is necessary to be executed for specialization in the derived class.
This definition was written in the context of C#
Share this:

Connect with us

Email Newsletter

Join thousands of others with our weekly newsletter

The 4th Era of IT Infrastructure: Superconverged Systems
The 4th Era of IT Infrastructure: Superconverged Systems:
Learn the benefits and limitations of the 3 generations of IT infrastructure – siloed, converged and hyperconverged – and discover how the 4th...
Approaches and Benefits of Network Virtualization
Approaches and Benefits of Network Virtualization:
Businesses today aspire to achieve a software-defined datacenter (SDDC) to enhance business agility and reduce operational complexity. However, the...
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.