Introduction:

In this article we will explain how to use protected internal modifier or specifier  in c# or What protected internal modifier or why use protected internal modifier in c# or how to allows variables and methods to accessing another  namespace  or Application in c# with example.

Description:

The "protected internal" access modifier is a combination of both the "protected" and "internal" modifiers. The protected internal access modifier allows its variable and function to be accessed in derived class another application and containing class or classes within same application.

Example of C# protected internal Access Specifier

Let's take an example to demonstrate C# protected internal Access Specifier

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 Product;            // decimal Variabledeclared as protected internal            protected internal decimal Rate;            public void print()            {
     Console.WriteLine("\nProduct Name : " + Product);
     Console.WriteLine("\nRate : " + Rate);            }    }    class Program    {            static void Main(string[] args)            {
            access ac = new access();
            Console.Write("Enter Product name:\t");
            // Accepting value in protected internal variable
            ac.Product = Console.ReadLine();
            Console.Write("Enter Product Rate:\t");
            // Accepting value in protected internal variable
            ac.Rate = Convert.ToDecimal( Console.ReadLine());
            ac.print();
            Console.ReadLine();            }      }
}

Output:

protected internal in c# with example


I hope this article will help to you.

0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

you may also like