A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

© 卖火柴 中级黑马   /  2013-12-21 10:51  /  925 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

internal 修饰符起什么作用
答:
internal 修饰符可以用于类型或成员,使用该修饰符声明的类型或成员只能在同一程集内访问
接口的成员不能使用 internal 修饰符
示例
Example05Lib 项目的 Class1

CODE:

using System;
using System.Collections.Generic;
using System.Text;
namespace Example05Lib
{
    public class Class1
    {
        internal String strInternal = null;
        public String strPublic;
    }
}
结果
Example05Lib 项目的 Class2 类可以访问到 Class1 的 strInternal 成员

Example05 项目的 Program 类无法访问到 Class1 的 strInternal 成员

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马