Difference between struct and class
The most important thing is the difference between value and object.
However, it is very important to find another interesting phenomenon recently.
In a project, struct is used because of various structures. However, it is a little troublesome. Passing values consumes a lot and does not like REF (because I like to write generic functions)
So we adopted the class, and then we went smoothly .....
[Serializable] // indicates serializable [structlayout (layoutkind. sequential, charset = charset. ANSI, pack = 1)] // tiled structure; ANSI characters; each structure member is aligned by 1 byte [rdmsgid (rdmsgid. e_fid_mc_marketinfo)] class marketinfo {[financialas (unmanagedtype. byvalarray, sizeconst = 5)] public marketdatatick [] marketdataticks ;}
It should be said that marshal. sizeof (marketinfo) is equal to sizeof (marketdatatick) * 5
But actually: 4*5 = 20
Why? Because the structure of marketdatatick is set to class, it is easy to change it to struct!
Tragedy!