Lecture overview -- Keyboard shortcut: 'u'  Previous page: Illustration of variables of value types -- Keyboard shortcut: 'p'  Next page: Structs and Initialization -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Alphabetic index  Help page about these notes  Course home    Reference types, Value types, and Patterns - slide 10 : 29

Structs in C#

We show the structs Point and Card

Point.cs
Struct Point.
PlayingCard.cs
Struct Card.
Client.cs
A client of struct Card.

Structs are typically used for aggregation and encapsulation of a few values, which we want to treat as a value itself, and for which we wish to apply value semantics

In the System namespace, the types DateTime and TimeSpan are programmed as structs