C# Protected Internal Access Specifiers

In this chapter you will learn:
  • What is protected internal access specifier?
  • What is the boundary of protected internal access specifier?
  • How to use protected internal access specifier in C# programming?

The protected internal access specifier allows its members to be accessed in derived class, containing class or classes within same application. However, this access specifier rarely used in C# programming but it becomes important while implementing inheritance.

 

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Protected_Internal
{
    class access
    {
        // String Variable declared as protected internal
        protected internal string name;
        public void print()
        {
            Console.WriteLine("\nMy name is " + name);
        }
    }


    class Program
    {
        static void Main(string[] args)
        {
            access ac = new access();
            Console.Write("Enter your name:\t");
            // Accepting value in protected internal variable
            ac.name = Console.ReadLine();
            ac.print();
            Console.ReadLine();
        }
    }
}

Output

Enter your name:     Steven Clark
My name is Steven Clark __

Summary

In this chapter you learned about protected internal access specifier in C#. In next chapter you will learn get set modifier in C#.

More Articles

 

Share your thought



PLEASE DISABLE ADBLOCKER AND SUPPORT US!

Please support us by enabling ads on this page. Refresh

YOU DON'T LIKE ADS, WE ALSO DON'T LIKE ADS!
 
But we have to show ads on our site to keep it free and updated. We have to pay huge server costs, domain costs, CDN Costs, Developer Costs, Electricity and Internet Bill. Your little contribution will encourage us to regularly update this site.