Designing a New Value Type
C# allows a user to create their own structs. This is useful if there is a need for creating a new value type, an object with value semantics. Struct creation is much like designing a new class. There are differences and the following paragraphs will show what they are. The following example provides a general description of the syntax of creating a struct.
[modifiers] struct Name [: Interface [, Interfaces]] { // non-default constructors // fields // methods // properties // indexers // events // delegates // enumerations // structs }
A struct's optional modifiers are the same as a class. Of course, the primary exceptions are that structs don't have abstract and sealed modifiers. They can't have a protected modifier, ...
Get C# Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.