Modifiers for C # common objects

Source: Internet
Author: User

Class (classes)

1.internal indicates that a class can only be accessed in the course assembly, class default modifier

2.public means that all places can be accessed, and internal is mutually exclusive

3.abstract abstract class, cannot be instantiated, can only inherit

4.sealed sealed class, can not be inherited, and astract is mutually exclusive

Interface (interface)

1.public means all places are accessible, interface default modifier

2.internal tables can only be accessed in the course assembly only

Note: Interfaces cannot be abstract and sealed, which is meaningless for the interface

Members of the Class (Fields, methods, properties)

1.private only the internal access of the current class, the default modifier of the member

2.protected only the current class or subclass from the current class can access

3. Internal the current assembly can access

4. Internal protected the current Assembly inherits his subclasses can access

5. No restrictions on public

6. Static success of a member in the static table can be used with the above access modifier to indicate that the class itself is called and cannot be invoked using an instance object

7. readonly only valid for fields, can be used with other modifiers, read-only fields in the table

Other modifiers of the method

1.virtual means the method can be overridden

2.abstract means that the method must be overridden, that there is no method body, and that the class with the abstract method must be an abstract class

3.override means overriding a method in a base class

4.extern means definition of method in other places

5.new represents a class method of a derived class to hide a base class method;

6.this indicates a pointer to the current class instance reference,

7.base indicates that the keyword points to the base class instance reference

Member of Interface (field, method, property)

1.public, generally do not write manually, the default is public

Modifiers for C # common objects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.