C# Internal Access Specifiers

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

The internal access specifier hides its member variables and methods from other classes and objects, that is resides in other namespace. The variable or classes that are declared with internal can be access by any member within application. It is the default access specifiers for a class in C# programming.

 

Example:

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

namespace Internal_Access_Specifier
{
    class access
    {
        // String Variable declared as internal
        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 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 internal access specifier, its boundary and scope and implementation in program. In next chapter you will learn protected internal access specifier 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.