protected
An access modifier that lets a member be used inside its own class and in classes that inherit from it.
What is protected in C#?
protected — An access modifier that lets a member be used inside its own class and in classes that inherit from it, but not from anywhere else.
class Account
{
protected decimal balance = 20m;
}
class SavingsAccount : Account
{
public void AddInterest()
{
balance += balance * 0.02m; // allowed: SavingsAccount inherits from Account
}
}
Level: Journeyman · More C# terms at this level
Updated