Static, abstract class, interface, class library, abstract class library
1. Common Member
Common members belong to objects.
Call with object
2. Static members
Static members belong to the class
Called by Class Name
Stactic static keywords
Static methods cannot contain common members.
The common method can contain static members.
Abstract class:
1. Keywords: abstract
2. abstract classes can contain abstract methods and common methods.
3. abstract keywords can define methods as abstract methods. abstract methods can have no function bodies.
4. abstract classes cannot be instantiated. abstract classes are mainly used as a base class to inherit other classes.
5. The sealed and abstract keywords cannot appear at the same time.
6. If a subclass inherits from an abstract class, all abstract methods must be implemented in the subclass.
7. If the subclass does not implement the abstract method of the parent class, the subclass must be an abstract class.
8. If a class contains abstract methods, the class must be an abstract class.
Interface:
An extremely abstract class.
Head Office-rules and regulations (interfaces)-the company must perform attendance on its employees
Subsidiary Company 1-following the rules and regulations of the company-implementing attendance-punching
Subsidiary Company 2-following the rules and regulations of the company-implementing attendance-naming
Differences between interfaces and abstract classes:
1. Differences in writing
Keyword: interface
Class names without class keywords generally start with I
You don't need to write public because it is public and you don't need to write abstract interfaces.
Like
2. The interface cannot contain common members.
3. All classes that inherit interfaces must implement methods in interfaces.
// Class library
Class must be public access permission
A dll file is a class library. It can be used but cannot be modified.
Sometimes we need to use classes written by others
1. If the class is a source code class. cs File
After getting the file to the project, you can choose to add a new item or add an existing item.
Introduce the corresponding namespace
2. If the class is not the source code, but the compiled. dll file (the compiled Class Library)
Get the file to the project, add reference, browse, and find the. dll file.
Introduce the corresponding namespace