internal修饰符起什么作用
internal 修饰符可以用于类型或成员,使用该修饰符声明的类型或成员只能在同一程集内访问
接口的成员不能使用 internal 修饰符
值得注意的是,如果为 internal 成员加上了 protected 修饰符,这时的访问级别为 internal 或 protected。只是看字面意思容易弄错,许多人认为 internal protected 应该是“只有同一个程序集中的子类可以访问”,但其实它表示“同一个程序集中的所有类,以及所有程序集中的子类都可以访问”
示例
Example05Lib 项目的 Class1
using System;
using System.Collections.Generic;
using System.Text;
namespace Example05Lib
{
public class Class1
{
internal String strInternal = null;
public String strPublic;
internal protected String strInternalProtected = null;
}
}
接口的成员不能使用 internal 修饰符
值得注意的是,如果为 internal 成员加上了 protected 修饰符,这时的访问级别为 internal 或 protected。只是看字面意思容易弄错,许多人认为 internal protected 应该是“只有同一个程序集中的子类可以访问”,但其实它表示“同一个程序集中的所有类,以及所有程序集中的子类都可以访问”
示例
Example05Lib 项目的 Class1
using System;
using System.Collections.Generic;
using System.Text;
namespace Example05Lib
{
public class Class1
{
internal String strInternal = null;
public String strPublic;
internal protected String strInternalProtected = null;
}
}
【internal修饰符起什么作用】相关文章
3. new修饰符是起什么作用
4. 介绍一下ICMP(Internet Control Message Protocol)Internet控制信息协议
5. 简述你对Statement,PreparedStatement,CallableStatement的理解
6. Linux Interview Questions For software testers
9. 如何反序的迭代一个序列?how do I iterate over a sequence in reverse order
10. swtich是否能作用在byte上,是否能作用在long上,是否能作用在String上
本文来源:https://www.mianshiwenti.com/a12988.html
进入下载页面
上一篇:C#基础面试题
下一篇:C#中有没有运算符重载?能否使用指针?
﹝internal修饰符起什么作用﹞相关内容
- swtich是否能作用在byte上,是否能作用在long上,是否能作用在String上?
- 什么是触发器(trigger)? 触发器有什么作用?
- 说说在weblogic中开发消息Bean时的persistent与non-persisten的差别
- Internet主要有哪些网络群组成
- Internet体系结构
- 四川internet信息高速公路(C#)笔试题
- int和Integer有什么区别
- Java 中访问数据库的步骤?Statement 和PreparedStatement 之间的区别?
- What\'s the difference between an interface and abstract class? (接口与抽象类有什么区别)
- JSF面试题:Jsf中的核心类用那些?有什么作用?LiftCycle六大生命周期是什么?