C# language refference_8

Members that contain executable code are collectively known as the function members of the class. The function members of a class are the methods, properties, indexers, operators, constructors, and destructors of the class. A class-declaration creates a new declaration space (§), and the class-member-declarations immediately contained by the class-declaration introduce new members into this declaration space. The following rules apply to class-member-declarations: • • • Constructors and destructors must have the same name as the immediately enclosing class. All other members must have names that differ from the name of the immediately enclosing class. The name of a constant, field,. | Chapter 10 Classes Members that contain executable code are collectively known as the function members of the class. The function members of a class are the methods properties indexers operators constructors and destructors of the class. A class-declaration creates a new declaration space and the class-member-declarations immediately contained by the class-declaration introduce new members into this declaration space. The following rules apply to class-member-declarations Constructors and destructors must have the same name as the immediately enclosing class. All other members must have names that differ from the name of the immediately enclosing class. The name of a constant field property event or type must differ from the names of all other members declared in the same class. The name of a method must differ from the names of all other non-methods declared in the same class. In addition the signature of a method must differ from the signatures of all other methods declared in the same class. The signature of an indexer must differ from the signatures of all other indexers declared in the same class. The signature of an operator must differ from the signatures of all other operators declared in the same class. The inherited members of a class are specifically not part of the declaration space of a class. Thus a derived class is allowed to declare a member with the same name or signature as an inherited member which in effect hides the inherited member . Inheritance A class inherits the members of its direct base class. Inheritance means that a class implicitly contains all members of its direct base class except for the constructors and destructors of the base class. Some important aspects of inheritance are Inheritance is transitive. If C is derived from B and B is derived from A then C inherits the members declared in B as well as the members declared in A. A derived class extends its direct base class. A derived class can add new members

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.