zoukankan      html  css  js  c++  java
  • 访问修饰符

    public

    同一程序集中的任何其他代码或引用该程序集的其他程序集都可以访问该类型或成员。

    The type or member can be accessed by any other code in the same assembly or another assembly that references it.

    private

    只有同一类或结构中的代码可以访问该类型或成员。

    The type or member can be accessed only by code in the same class or struct.

    protected

    只有同一类或结构或者此类的派生类中的代码才可以访问的类型或成员。

    The type or member can be accessed only by code in the same class or struct, or in a class that is derived from that class.

    internal

    同一程序集中的任何代码都可以访问该类型或成员,但其他程序集中的代码不可以。

    The type or member can be accessed by any code in the same assembly, but not from another assembly.

    protected internal

    由其声明的程序集或另一个程序集派生的类中任何代码都可访问的类型或成员。 从另一个程序集进行访问必须在类声明中发生,该类声明派生自其中声明受保护的内部元素的类,并且必须通过派生的类类型的实例发生。

    The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. Access from another assembly must take place within a class declaration that derives from the class in which the protected internal element is declared, and it must take place through an instance of the derived class type.

    1. protected的权限和private的权限很相似,唯一不同的是protected类或成员可以被子类继承,而private类型成员不可以被继承。
    2. 类的默认修饰符符是internal.成员的默认修饰符是private.
  • 相关阅读:
    MariaDB + Visual Studio 2017 环境下的 ODBC 入门开发
    CUDA 9.1/9.2 与 Visual Studio 2017 (VS2017 15.6.4) 的不兼容问题
    用 SDL2 在屏幕上打印文本
    用 SDL2 处理精灵图
    用 SDL2 进行事件驱动编程
    用 SDL2 加载PNG平铺背景并显示前景
    用 SDL2 平铺背景并显示前景
    用 SDL2 显示一张图片
    VPS 安全措施(CentOS 6)
    Hello World!
  • 原文地址:https://www.cnblogs.com/Jeffli91/p/public_internal_proctectd_private.html
Copyright © 2011-2022 走看看