Structs in .NET - ablealias/asp.net GitHub Wiki
The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color. Structures are used to represent a record. It is an error to define a default (parameterless) constructor for a struct. It is also an error to initialize an instance field in a struct body. You can initialize struct members only by using a parameterized constructor or by accessing the members individually after the struct is declared. Any private or otherwise inaccessible members can be initialized only in a constructor.
Structures can have methods, fields, indexers, properties, operator methods, and events.
Structures can have defined constructors, but not destructors. However, you cannot define a default constructor for a structure. The default constructor is automatically defined and cannot be changed.
-
Unlike classes, structures cannot inherit other structures or classes.
-
Structures cannot be used as a base for other structures or classes.
-
A structure can implement one or more interfaces.
-
Structure members cannot be specified as abstract, virtual, or protected.
-
When you create a struct object using the New operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the New operator.
-
If the
New operator is not used, the fields remain unassigned and the object cannot be used until all the fields are initialized
. -
classes are reference types and structs are value types
-
structures do not support inheritance
-
structures cannot have default constructor