Clear structure
Good maintainability and robustness
Good extensibility
Class is the most basic unit used in the
Self-written classes-user-defined types
If the object to be produced by using a custom type must have an instantiated procedure
Instantiation format:
Type name SS = new type name ();
Access Modifier-4
Public-publicly available, accessible anywhere, but with reference to namespaces
Private-The inside of the class can only be accessed
Internal-Internal, default, assembly accessible, assembly is namespace
Protected-protected, class-Inside and class-parent classes and subclasses can be accessed
Packaging:
Private data type _ name; --Member variable/field
Public default consistent name--property
{
get{return _ name;} --Obtained by default
set{_ name = value;} --Assigned value
}
Encapsulation can protect the security of your data.
Quick Package shortcut key: Ctrl+r+e
Inherited:
A subclass has a parent class that can inherit all the public properties and methods of the parent class.
A parent class can have countless subclasses
The higher the parent, the more abstract, the lower the more specific the child.
Inherited syntax: Class Name: Parent class name (write a colon directly after the class name and the parent class name that you want to inherit)
A:b left is subclass, right is parent class
Subclass is also called XXX's derived class, Super class
The parent class is also called the base class
Polymorphic:
Subclasses have a variety of forms, can inherit from the parent class, or they can be different from the parent class
Virtual method Virtual
overriding override
The methods in the parent class are not applicable in subclasses, then the subclass needs to change the inherited methods or attributes autonomously, and the method of adding the virtual keyword to the parent class can be overridden by the subclasses.
Subclasses override the parent class by using the Override keyword
Parent class:
public class Fly {public virtual string Fling () { return "flapping wings can fly!!!" "; } }
Sub-class:
public class Plane:fly {public override string Fling () { return "Fire can fly!!!" "; } }
C # Object-oriented