C# Protected Internal访问修饰符示例
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Internal_Access_Specifier { class accessmod { //定义为 protected internal protected internal string name; public void print() { Console.WriteLine("\nMy name is " + name); } } class Program { static void Main(string[] args) { accessmod nam = new accessmod(); Console.Write("Enter your name: "); //访问内部变量的值 nam.name = Console.ReadLine(); nam.print(); Console.ReadLine(); } } }
受保护的内部访问修饰符允许其成员在同一组件中的任何类中访问,包括派生类。
但是,此访问修饰符很少用于CPRAGICMING,但当我们希望在程序中使用遗产概念时,它变得重要。
Protected Internal可访问性表示 protected或者 Internal 而不是 Protected并且Internal
日期:2020-04-11 23:03:48 来源:oir作者:oir