Lecture overview -- Keyboard shortcut: 'u'  Previous page: Structs versus classes -- Keyboard shortcut: 'p'  Next page: Examples of immutable structs in C# -- 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 13 : 29
Object-oriented Programming in C#
Reference types, Value types, and Patterns
Examples of mutable structs in C#

The purpose of this page is to point out the misfit between value types (C# structs) and mutability. This page should be used as motivation for the solutions on the following page.

Examples of struct Point

The examples on this page illustrate mutable Points programmed with structs

 

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


/user/normark/oop-csharp-1/sources/c-sharp/point/struct-mutable-1/MoveClient.csMoving a point by mutation.


/user/normark/oop-csharp-1/sources/c-sharp/point/struct-mutable-1/outputOutput from the application.


/user/normark/oop-csharp-1/sources/c-sharp/point/struct-mutable-2/Point.csThe struct Point - mutable, where move returns a Point.


/user/normark/oop-csharp-1/sources/c-sharp/point/struct-mutable-2/Client.csApplication the struct Point - Cascaded moving.


/user/normark/oop-csharp-1/sources/c-sharp/point/struct-mutable-2/outputOutput from the application.