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 and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 10 : 29
Object-oriented Programming in C#
Reference types, Value types, and Patterns
Structs in C#

Structs in C# are value types. On this page we show two concrete programming examples of structs.

We show the structs Point and Card

/user/normark/oop-csharp-1/sources/c-sharp/point/struct-mutable-1/Point.csStruct Point.

/user/normark/oop-csharp-1/sources/c-sharp/playing-card/playing-card-struct/PlayingCard.csStruct Card.

/user/normark/oop-csharp-1/sources/c-sharp/playing-card/playing-card-struct/Client.csA 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