Why storage overhead generates waste in C# data types?
.net, c#
Solution
Each `byte` field occupies 1 byte, whilst each `long` field occupies 8 bytes. This means that, whilst `b` could be placed anywhere in memory, `l` needs to be placed at an address that is a multiple of 8. It cannot be placed at address `0` since that is already occupied by `b`; thus, it must be placed at the next available multiple of 8, which is `8`, causing the 7 bytes of intervening space to be wasted.
---------------------------------------------------------------------------------
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
---------------------------------------------------------------------------------
<--b-> <------------------l-------------------->
<--------------waste------------->
Problem
In subtopic Storage Overhead (on Chapter) -C# 5.0 in a Nutshell book- there is this general note that says: Now, I'm wondering why the fields in struct A generates a waste of space? Or, what is the author's point with the entire note?