hi every one i have few question
1)
class ClassName
{
public int[] a = new int[100];
}
what happens when object of this class is created i mean where is the array of integers stored at, on the Stack [value type] or on the Heap [Reference Type]
i am confused as per the specs value types are stored on Stack then the array will be stored on stack .
but the Reference types are created on Heap as per the specs
please guys help me understand this . i dont want to write code without knowing what is happening behind the scenes
thanks in Advance
There are no value types here. So the question is moot. Both ClassName and int[] are reference types.
If a value type is declared as an automatic local it is stored on the stack. If it is declared inside another type, it is stored inside that other type.
It is one of the great un-dying myths of C# that value types are always stored on the stack.