I found that class usage is not a good habit in C #, so now I will study the knowledge of lightweight struct.
Struct (struct) is actually very similar to the class, but there are also many differences. The following is a list:
- Struct is a value type, while a class is a reference type. this means that the struct is lightweight and stored on the stack and will not be recycled by the garbage collector. it is more appropriate to use struct when you think about how to organize some data together. you do not need to work with the public.
- Struct does not support inheritance and cannot be used for derivation. However, constructors and methods can be implemented.
- The struct can have 0 or more constructors and methods, but cannot contain constructors without parameters.
- The struct does not have a destructor (because it will not be recycled by the garbage collector ?)
It's only so much. Oh, it seems that I am really stupid. I want to review it later. This is the structure. Remember to use it when appropriate.