C# Programming - Interfaces - Discussion
Discussion Forum : Interfaces - General Questions (Q.No. 3)
3.
A class implements two interfaces each containing three methods. The class contains no instance data. Which of the following correctly indicate the size of the object created from this class?
Discussion:
15 comments Page 2 of 2.
BhanuPriya Singh said:
1 decade ago
How can we identify that what is the size of method?
Nisha Gobi said:
1 decade ago
What is the method of finding the size of Method?
Parul said:
1 decade ago
In C#, for reference types (class, not struct), it is always equal to the size of a pointer (4 on 32 bit systems).
Since it has six methods in all, means size will be 6*4 = 24 bytes.
Since it has six methods in all, means size will be 6*4 = 24 bytes.
Manas Sinha said:
1 decade ago
Its correct with 24 Bytes with 6*4 = 24 bytes way. And do not have to think about initialized or not, it is true that until initialized it will not occupy space, but this is not in the scope of the question. It says object created, does not say initialized or not!
SharadBS said:
1 decade ago
As per http://stackoverflow.com/questions/3694423/size-of-a-class-object-in-net
For 32 bit it will be 24.
Quote taken from link says.
"classes have a memory minimum of 12 bytes and fields with reference types are 4 bytes on 32-bit systems and 8 bytes on 64-bit systems."
Is there any way to getting the size of heap through code?
I tried using int sizeInBytes = Marshal.SizeOf(typeof(MyClass));
It says 1 byte on 64-bit machine.
Somehow explained in http://msdn.microsoft.com/en-us/magazine/cc163791.aspx
But still I want to see the bytes through code.
For 32 bit it will be 24.
Quote taken from link says.
"classes have a memory minimum of 12 bytes and fields with reference types are 4 bytes on 32-bit systems and 8 bytes on 64-bit systems."
Is there any way to getting the size of heap through code?
I tried using int sizeInBytes = Marshal.SizeOf(typeof(MyClass));
It says 1 byte on 64-bit machine.
Somehow explained in http://msdn.microsoft.com/en-us/magazine/cc163791.aspx
But still I want to see the bytes through code.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers