---
title: "Protected Access modifier C#"  
description: "Protected Access modifier C#"  
author: "Anonymous User"  
published: 2015-11-25  
updated: 2015-11-25  
canonical: https://www.mindstick.com/forum/33638/protected-access-modifier-c-sharp  
category: "c#"  
tags: ["c#", ".net"]  
reading_time: 1 minute  

---

# Protected Access modifier C#

I want to know what is [Protected Access](https://www.mindstick.com/forum/156707/what-is-the-difference-between-public-private-and-protected-access-modifiers) modifier and how to use please help me.

## Replies

### Reply by Anonymous User

The protected [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) modifier 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.

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Protected_Modifier {    class ProtectedClass    {        // String Variable declared as protected        protected string ComputerName;        public void print()        {            Console.WriteLine("\nMy name is " + ComputerName);        }    }    class MainClass : ProtectedClass // Inherit access class    {        static void Main(string[] args)        {            MainClass p = new MainClass();            Console.Write("Enter your CounputerName:\t");            p.ComputerName = Console.ReadLine(); // No Error!!            p.print();            Console.ReadLine();        }    }}
```

![Protected Access modifier C#](https://www.mindstick.com/mindstickforums/efab8a58-9051-4d3a-8da8-40d67c36bf17/images/57ceb31b-8cde-4645-8264-2e3586a62683.png)


---

Original Source: https://www.mindstick.com/forum/33638/protected-access-modifier-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
