Well array in general its a grouping of similar datatypes [int or char or string] :) as all know it
But my doubt is, FIXED length types are VALUES types if i am not wrong ?? so we can store them in stack :)
While memory allocated at run-time like strings ,objects etc are variable length humm .!! so they are reference types [storage:managed heap]:) right ?
SO problem is ARRAY is a fixed length type even tough it called as Reference types why cant we call it as value type :( ?
I guess as array's group's strings also that's why its called as reference type as string is a reference type
Hope everyone got my problem & waiting for your solution in general in ur own view :) no links plz for this
TY

VulpesPosted Mar 14, 2013, 5:47 AM
However, as it happens, the amount of heap memory occupied by the array object itself is also fixed.
As you said, when it's an array of value types (int, bool, double, char etc) each element of the array contains the value type itself which requires a fixed amount of storage - 4 bytes for an int, 1 byte for a bool, 8 bytes for a double, 2 bytes for a char etc.
When its an array of reference types, each array element contains a reference (i.e. a pointer) to where the actual reference type object is stored elsewhere on the heap. These references are also fixed in size - 4 bytes on a 32-bit system and 8 bytes on a 64-bit system.
So, if you had an array of 10 strings on a 32-bit system, the array elements would occupy 40 bytes on the heap. The strings themselves, which would be stored elsewhere on the heap, would (ignoring overhead) need 2 x n bytes where n is the length of the string (each unicode character requires 2 bytes of storage).
VulpesPosted Mar 15, 2013, 3:20 PM
SUNIL GUTTAPosted Mar 15, 2013, 1:44 PM
ignoring overhead ? U said that .. well what excatly overhead contains as it occupies 2bytes in heap out of 4 ?
VulpesPosted Mar 15, 2013, 12:53 PM
SUNIL GUTTAPosted Mar 15, 2013, 11:56 AM
each unicode character requires 2 bytes of storage ??
this means if humm lets take this string in array like "Vulpes" :) so total memory on heap will be 2 * 2(6) = 24 bytes of memory haaa ??
TY
VulpesPosted Mar 14, 2013, 7:46 PM
There's an essential difference between an array of value types and an array of reference types. The former is entirely self contained and the latter contains references to the objects themselves which are stored outside the array.
SUNIL GUTTAPosted Mar 14, 2013, 8:07 AM
Well then i conclude on behalf of you :) array datatype can't be classified acc to their length[fixed or variable] but mainly done acc to their storage way[value or refernce] ri8 :)