zoukankan      html  css  js  c++  java
  • C# Programming Language学习笔记(四)

    第四章 基础概念
    1.Protected internal (meaning protected or internal), which is selected by including both a protected and an internal modifier in the member declaration. The intuitive meaning of protected internal is "access limited to this program or types derived from the containing class."
    Protected internal(意思是protected或者internal),在成员声明是同时选择protected和internal两个修饰符.protected internal的意思是"只有本程序内或者继承于该类的类型可以访问"
    2.Namespaces implicitly have public declared accessibility. No access modifiers are allowed on namespace declarations.
    Namespaces隐式地具有共有访问级别.在声明Namespaces的时候不允许用访问级别修饰符.
    3.Types declared in compilation units or namespaces can have public or internal declared accessibility and default to internal declared accessibility.
    在编译单元或者Namespaces声明的类型可以具有public或者internal访问级别,默认为internal访问级别.
    4.Class members can have any of the five kinds of declared accessibility and default to private declared accessibility. (Note that a type declared as a member of a class can have any of the five kinds of declared accessibility, but a type declared as a member of a namespace can have only public or internal declared accessibility.)
    类成员可以有五种访问级别,默认为private访问级别(注意,一个作为类成员定义的类型可以有任意五种访问级别中的一个,但是作为namespace成员定义的类型只能是public或者internal访问级别).
    5.Struct members can have public, internal, or private declared accessibility and default to private declared accessibility because structs are implicitly sealed. Struct members introduced in a struct (that is, not inherited by that struct) cannot have protected or protected internal declared accessibility. (Note that a type declared as a member of a struct can have public, internal, or private declared accessibility, but a type declared as a member of a namespace can have only public or internal declared accessibility.)
    结构成员可以具有public,internal,private访问级别,默认是private访问级别因为结构是隐式封闭的.结构中的结构类型成员(换句话说,不是那个结构的继承.译注:是组合不是继承)不能有protected或者protected internal访问级别.(注意作为结构的成员声明的类型可以具有public,internal或者private访问级别,但是作为命名空间成员申明的类型只能有public或者internal访问级别).
    6.Interface members implicitly have public declared accessibility. No access modifiers are allowed on interface member declarations.
    Enumeration members implicitly have public declared accessibility. No access modifiers are allowed on enumeration member declarations.
    接口和枚举成员隐式地具有public访问级别.接口和枚举成员不能有访问修饰符.
    7.Note that any ref and out parameter modifiers are part of a signature. Thus, F(int) and F(ref int) are unique signatures. Also, note that the return type and the params modifier are not part of a signature, so it is not possible to overload solely based on the return type or on the inclusion or exclusion of the params modifier. As such, the declarations of the methods F(int) and F(params string[]) identified in the previous example result in a compile-time error.
    注意ref和out参数修饰符都是签名的部分.因此,F(int)和F(ref int)都是唯一的签名.另外,返回类型和params修饰符不是签名的部分,所以不能仅仅根据返回类型或者是否包含params修饰符来判定重载.于是,F(int)和F(params string[])在前面的例子中引发了编译时错误.
    译注:上文中提到的引发编译时错误的语句如下:
    interface ITest

    {

        
    void F();                      // F()

        
    void F(int x);                 // F(int)

        
    void F(ref int x);             // F(ref int)

        
    void F(int x, int y);          // F(int, int)

        
    int F(string s);               // F(string)

        
    int F(int x);                  // F(int)       error

        
    void F(string[] a);            // F(string[])

        
    void F(params string[] a);     // F(string[])  error

    }


    8.A constant, field, property, event, or type introduced in a class or struct hides all base class members with the same name.
       A method introduced in a class or struct hides all nonmethod base class members with the same name and all base class methods with the same signature (method name and parameter count, modifiers, and types).
       An indexer introduced in a class or struct hides all base class indexers with the same signature (parameter count and types).
       The rules governing operator declarations  make it impossible for a derived class to declare an operator with the same signature as an operator in a base class. Thus, operators never hide one another.

       常量,字段,属性,事件或者类或结构中的类型 隐藏了基类中的同名成员.
       类或结构的方法隐藏了基类中的同名非方法成员和具有相同签名的方法成员(方法名和参数个数,形式和类型).
       类或者结构中的index隐藏了基类中具有相同签名的index(参数个数和类型)
       操作符的声明规则使得不可能在派生类中声明一个具有和基类同样签名的操作符.所以,操作符永远不会相符覆盖.
    4-9章分别介绍类型,变量,转换,表达式,语句和命名空间.这些部分内容就不再看了.

  • 相关阅读:
    Ajax原生请求及Json基础
    HTML5拖拽练习
    表格单元格间数据的拖拽
    query 获取本身的HTML
    JQuery UI的拖拽功能实现方法小结
    ASP.NET MVC4中使用bootstrip模态框时弹不出的问题
    窗口中各模块的切换效果,使用jquery实现
    窗口模块自适应高度
    新jQuery中attr 与 prop的不同
    用js+css3做一个小球投篮的动画(easing)
  • 原文地址:https://www.cnblogs.com/Farseer1215/p/260045.html
Copyright © 2011-2022 走看看