C# Programming - Structures - Discussion

Discussion Forum : Structures - General Questions (Q.No. 7)
7.
How many bytes will the structure variable samp occupy in memory if it is defined as shown below?
class Trial
{ 
    int i; 
    Decimal d;
}
struct Sample
{
    private int x; 
    private Single y; 
    private Trial z;
}
Sample samp = new Sample();
20 bytes
12 bytes
8 bytes
16 bytes
24 bytes
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
12 comments Page 2 of 2.

God Tuss Great ho said:   1 decade ago
Answer is correct. Beacause each type is behave like a integer and integer size should be 4 so answer is 12.

Singham said:   1 decade ago
Answer should be 28, because decimal = 16, int = 4, single = 4.


Post your comments here:

Your comments will be displayed after verification.