Protected Access Specifiers C#

protected-specifiers
In this chapter you will learn:

  • What is protected access specifier?
  • What is the boundary of protected access specifier?
  • How to use protected access specifier in C# programming?

The protected access specifier hides its member variables and functions from other classes and objects. This type of variable or function can only be accessed in child class. It becomes very important while implementing inheritance.

Example:

Output

‘Protected_Specifier.access.name’ is inaccessible due to its protection level.
This is because; the protected member can only be accessed within its child class. You can use protected access specifiers as follow: __

protected access-specifiers

Example:

Output

Enter your name:     Steven Clark

My name is Steven Clark
__

Summary

In this chapter you learned about protected access specifier. You also learned its boundary and scope and implementation in a program. In next chapter you will learn about internal access specifier in C#.



2 thoughts on “Protected Access Specifiers C#”

  1. Greetings Sir,
    i just need opinion on a point that can we use protected specifier in other assembly also. if we inherit that class in class of other assembly. is it possible ???

Leave a Reply

Your email address will not be published. Required fields are marked *