It is said that valuetype derives from system.object. Why do object derived classes take more space than valuetype structures?
Thanks in advance
It is said that valuetype derives from system.object. Why do object derived classes take
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Every object has an object header. That’s 8 bytes on a 32-bit machine, 4 for the sync block and 4 for the type handle. A value type value only derives from System.Object when it is boxed. An int is 4 bytes when it unboxed, 12 bytes when it is boxed, +8 bytes for the header.
Check this answer to get more insight in what a boxed value type looks like.