Differences between struct and classes in C #
1. struct is a value type, and class is a reference type
Although the new operator is used for struct initialization, struct objects are still allocated to Stacks rather than stacks. If the new operator is not used ),
Before initializing all fields, the fields remain in the unassigned status and the object is unavailable.
2. struct cannot be inherited from another structure or class. Although the structure is not explicitly declared using sealed, the structure is implicitly sealed.
The class is completely extensible. Unless the declared sealed is displayed, the class can inherit other classes and interfaces, and its own can also be inherited.
Although the structure cannot be inherited, the structure can inherit interfaces. methods are the same as class inheritance interfaces.
3. structure:
No default constructor exists, but you can add constructor.
No destructor
No abstract and sealed (because it cannot be inherited)
The protected modifier cannot exist.
You do not need to use new for initialization.
It is incorrect to initialize the instance field in the structure.
Class:
Default constructor available
Destructor
Abstract and sealed can be used.
There is a protected Modifier
New must be used for initialization.