6.18 (Inherit + (four-class access modifier + assembly + static method) outline

Source: Internet
Author: User

Inherited:

First, what is inheritance

Concept: The father has something, and allows inheritance , all children will have

A parent class can have more than one child class

A subclass can have only one parent class

Ii. conversion between father and son

A subclass can be converted to a parent class, which can only be converted to a previous subclass

Sub-classes cannot be converted between each other

-----------------------------------------------------------------------------

1. Access modifier:

One 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. (Less than a detailed example of the current use)

(When not in the same namespace: Import namespaces can work correctly; method: Instantiate + Right-click class name → Parse →using Class)

Protected: Protected, can only be accessed in his own and in his own subclasses. (Less than a detailed example of the current use)

2. Namespace = assembly

Group name for a group of classes

3. 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 ();//instantiation

R.next (); --How to use non-static methods

Static methods, you can instantiate the object , you can not instantiate the object, directly using the class can be point out of use;

Console.Write (); --How to use static methods

(directly with the name of the class.)

6.18 (Inherit + (four-class access modifier + assembly + static method) outline

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.