Discussion :: Interfaces - General Questions (Q.No.3)
|Amol said: (Sep 16, 2011)|
|If function has size 4 then it get multiplied to 6=24|
|Parul Sahu said: (Dec 10, 2011)|
|I didn't understand.|
|Mukesh said: (Dec 22, 2011)|
|How can I understand the size of function which is created ?|
|Neelam said: (Feb 1, 2012)|
|Tell size of function which is created?|
|Abc said: (Mar 7, 2012)|
|Is there any restriction on size of the function?|
|Aishik said: (Jun 26, 2012)|
|The answer has to be 0byte....u dont know what is the predefined storage of the methods...initially it is 0....|
|Shubham said: (Jul 16, 2012)|
|No memory is allocated because there are no instance are created.
Size of the instance (object) is depended how much variable are initialized in the given class and inherits classes.
|Asish Kumar Satpathy said: (Jul 23, 2012)|
|The moment the object of the given class is initialized, the reference to those functions inside both the interfaces will occupy the memory. In C#.Net reference is of 4bytes.
Hence 4Bytes*3(1st interface)+4Bytes*3(2nd interface)=24Bytes
|Lakshmi Reddy Yeluri said: (Aug 29, 2012)|
|Good explanation Asish Kumar.
|Manish said: (May 1, 2013)|
|Class is initialized only then only reference is made. So, how the class will be initialized?
How class will be initialized without object creation. I mean to say how this class will be called from main method?
|Bhanupriya Singh said: (Nov 27, 2013)|
|How can we identify that what is the size of method?|
|Nisha Gobi said: (Jan 22, 2014)|
|What is the method of finding the size of Method?|
|Parul said: (Apr 22, 2014)|
|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.
|Manas Sinha said: (Sep 2, 2014)|
|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: (Sep 17, 2014)|
|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.
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.