Class Library
.dll file, use the library to help us to package some of the commonly used functions.
Static and non-static
Differences and similarities | Static state | Non-static |
---|---|---|
Whether static | Yes | no |
Whether the class can create objects | no | Yes |
member | There is only static members | Static and non-static available |
Calls member method | Static class name. Static method name | Instance name. Instance members |
Loading order | Static member is first loaded into memory and instance members | |
Release order | The entire project is over when released |
- Only the object is created, only instance members.
- The project should minimize the use of static variables
Scenarios static class
- Tools. For example: Console class
- Resource sharing throughout the project time.
Constructor / destructor sequence
- 1. The base class constructor
- 2. The class constructor
- 3. subclass destructor
- 4. The base class destructor
The initialization sequence
- 1. subclass of static variables
- 2. subclass static constructor
- 3. subclass of non-static variables
- 4. parent class static variables
- The parent class static constructor
- 6. parent class non-static variables
- 7. parent class constructor
- 8. subclass constructor