internal是类型或是类型成员的访问修饰符,表示类型或是其成员只能在同一程序集中被访问。

新建一个项目名为Internal,里边包含两个文件

internal关键字

在TestInternal中声明三个变量

 

 

public class TestInternal
{
internal string strFirst="Hello";
public string strSecond="Second";
string strThird="Third";
}

 

在TestSecond中访问TestInternal中的变量
internal关键字
可以看到能访问strFirst,因为他们在同一个程序集内。因为strSecond的修饰符是public所以也能访问,而strThird却不能访问。
新建一个项目Test
internal关键字
在Test中只能访问到strSecond,其他的都不能访问,因为不在同一个程序集内。
internal关键字

 
                    
            
                

相关文章:

  • 2022-12-23
  • 2021-06-21
  • 2022-12-23
  • 2022-12-23
  • 2021-04-10
  • 2022-12-23
  • 2021-09-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
相关资源
相似解决方案