Struct vs Class
We use a struct when:
- Primary purpose is to encapsulate a few relatively small data values.
- Reasonably expect encapsulated values to be copied rather than referenced when assigned or passed around.
- Any properties stored by a struct are themselves value types which should also be copied.
- The struct does not need to inherit properties or behaviours from another type.
If your purpose does not fit into the above, use a class.
< All Posts