Access modifiers and inheritance

Source: Internet
Author: User
Tags modifiers

Access modifiers:

Access modifiers are a permission limit for cross-class access

Public: The reference namespace is free to access, with the highest access rights.
Private: It can only be accessed in the class and structure in which it is declared, with the lowest access rights.

Internal: Internal, all classes in the same assembly can be accessed, and assemblies are namespaces.
Protected: Protected, can only be accessed in his own and in his own subclasses.

Inherited:

There are subclasses of the parent class that have and allow subclasses to inherit, a parent class can have more than one child class, and a subclass may have only a parent class.

Class bird:fly// front is subclass, followed by parent class

Subclasses can be converted to parent classes, which can only be converted to subclasses that were previously converted to the parent class.

static method:

Static methods and properties are used to define them;
Non-static methods need to instantiate the object and then invoke it with the object;
Random r = new Random ();
R.next (); --How to use non-static methods

static method, do not need to instantiate the object, directly with the class can point out to use;
Console.Write (); --How to use static methods

Access modifiers and inheritance

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.