value types are put into stack and class types get put into heap
Only half of that is true, specifically the second half. Reference types are stored in the heap, that is always true.
The first part is not true, or rather only true sometimes. Value types that are local variables are stored on the stack, but value types that are member of a class or struct are stored inside that type. Value types that are boxed are stored inside an object on the heap.
So, an instance of your MyClass
will contain an integer and a reference, and the instance of the class will always be stored on the heap.
The array is a separate object, and will also always be stored on the heap. If there actually is an array, that is. Until you have created an array and and assigned to myInts
, it's null
and there is no array.