Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the scope of a protected internal member variable of a class in C#?
The protected internal access specifier allows a class to hide its member variables and member functions from other class objects and functions, except a child class within the same application.
In the below example, the derived class object can access the protected internal variable.
Example
using System;
class One {
protected internal int a = 50;
private int b;
}
class Two : One {
public Two() {
Console.WriteLine(this.a);
}
}
class Demo {
static void Main() {
Two t = new Two();
// allowed since it is a derived class object
t.a = 20;
}
}
Output
50
Advertisements