Hi
How do you determine the size required by a Value type on the stack ?
How do you Determine the Size Required by a Value Type on the Stack
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Jul 9, 2012, 8:14 AM EDT
The sizeof operator is used to obtain the size in bytes for a value type.
Thanks
VulpesRank #55 · 29.2K reputationPosted Jul 9, 2012, 8:59 AM EDT
For example, this program won't compile because MyStruct contains a string field:
All you can do in these case is to work out the size manually - a reference needs 4 bytes on a 32-bit system or 8 bytes on a 64-bit system - though the matter is complicated by having to allow for 'padding' between fields as well.