When should you use struct and not class in C#? My conceptual model is that structs are used in times when the item is merely a collection of value types. A way to logically hold them all together into a cohesive whole.
I came across these rules here:
- A struct should represent a single
value. - A struct should have a memory
footprint less than 16 bytes. - A struct should not be changed after
creation.
Do these rules work? What does a struct mean semantically?
No comments:
Post a Comment