In-depth analysis of SQL encapsulation, polymorphism and heavy load, analysis of SQL polymorphism heavy load
Object-oriented
1. Class: abstracted by many objects
2. Object: the object instantiated by the class
3. Class Definition
Keyword class
4. The class contains
Member variables
Member attributes
Member Method
5. Three features of object-oriented
(1) Encapsulation
Objective: To make the class more secure.
Practice: Make the member variables in the class private, and perform corresponding methods or attributes to indirectly manipulate the member variables.
Encapsulate member methods to indirectly operate member variables in the class
Indirect member variables in the category using Member attributes
Access Modifier
Private
Protected can only be accessed in this class and its subclass.
Public can be accessed anywhere
Constructor (function ):
Purpose: Create the method to be called by the object to create an object and initialize the member.
Every class has a constructor. If you don't write it, you just can't see it.
Special: Special execution time
This Keyword:
This indicates the object, not the class
(2) Inheritance:
Concept: subclass can inherit everything in the parent class.
Features: One Child class can only have one parent class, and one parent class can have multiple child classes (all parent classes are objects)
Base keyword
Sealed Keyword: The sealed class cannot be inherited.
Partial classification: partial can split a class into multiple parts and put them in multiple files.
The namespace is equivalent to a virtual folder.
(3) polymorphism:
1. Compilation Polymorphism
Function overload
2. Run Polymorphism
Concept: when the parent class references a subclass instance, because the subclass overwrites the method of the parent class, the difference shown when calling this method is called polymorphism.
Condition: You must inherit the parent class references and point to the subclass instance subclass. You must override the method of the parent class.
Rys replacement principle: if a parent class object needs to be used, you can give it a subclass object.
1. Function Overloading
Conditions required for function overloading: The function name must be the same, and the number or type of parameters must be different.
2. this keyword
Although written in the class, it does not belong to the class, but belongs to the object
In general, the this keyword can be omitted in the class, but if there is a method parameter name that is the same as the member name, this keyword must be added when you call the members in the object.
3. is keyword
Determines whether a variable belongs to a certain type.
If (y2 is Ren) {s = "is a person";} else {s = "not a person ";}
4. as keywords
Conversion Type (only compatible types can be converted. Sub-class objects can be converted to parent class objects)
5. Inheritance
Subclass can inherit everything from the parent class
Features: single inheritance
One subclass can only have one parent class. One parent class can have multiple child classes.
C # special note: the ancestor of all classes is object
Base Keyword: indicates the parent class object in the subclass. The usage is the same as that of this keyword.
If the parent class has a constructor, the Child class also has a constructor. If the parent class requires a parameter, the Child class must also have a corresponding parameter.
After subclass construction, you can use base to call the construction method of the parent class.
public China(string m):base(m){ }
The preceding section describes SQL encapsulation, polymorphism, and overloading. I hope this will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!