In the linked post, the following is said:
Do not define a structure unless the type has all of the following characteristics:
- It logically represents a single value, similar to primitive types (integer, double, and so on).
- It has an instance size smaller than 16 bytes.
- It is immutable.
- It will not have to be boxed frequently.
I agree with these conditions.
#3 is a good point as you found in your "array[index].x++;" attempt. To modify a struct, you (in effect) MUST modify the entire struct, except in the very rare case where your struct instance is a local variable.
#1 follows from #3. If you must treat something as immutable, it should be treated as a single value.
The other two are performance considerations. I typically design applications based on behavior considerations first and only address performance if it bothers me, so I don't have personal experience fighting with them. I've *never* needed to use structs to address performance issues, and misuse of structs can actually hurt performance compared to classes.
Another "feature" of structs that I personally find to get in my way is that (without boxing them) they cannot be "null". You can use the nullable-type modifier, but that forces the variable to be boxed/unboxed.
You mention that you want a 16000x4000 array of these items, whatever they may be. I would personally either:
- Use a class (Even Terraria, with its huge 2D array of tiles, uses a class as its Tile type)
- Use struct-of-arrays (a separate array for each 'member' of your original struct). This might be good or bad depending on your situation, but at the very least you will be able to modify each individual "field" independently and without major headaches.