struct

Early on in this section, there was a discussion of value types and reference types. In C#, a struct is considered a value type and, as such, is managed on the stack rather than the heap. C# implements primitive types such as int and char as structs.

structs are best used for simple data types or mementos for object serialization and object state. structs can contain data members, methods, properties, and constructors. In most ways, a struct is similar to a class. However, a struct cannot inherit from a class or another struct, but can implement one or more interfaces. structs cannot contain constructors without parameters, and the compiler will issue an error if you attempt to define one.

The default protection level for struct members ...

Get C# and the .NET Framework: The C++ Perspective now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.