D
David Harmon
With regard to a declaration like:
Jesse Liberty, in _Programming Visual Basic .NET, 2nd Edition_
(O'Reilly) says:
Question:
Is that true? And if so, what happens when you return and the stack
gets popped, while a reference to the array created on the heap may
still exist somewhere?
Dim myIntArray As Integer = new Integer(6)
Jesse Liberty, in _Programming Visual Basic .NET, 2nd Edition_
(O'Reilly) says:
While VB.NET arrays are reference types, created on the heap, the
elements of an array are allocated based on their type. Thus,
myIntArray is a reference type allocated on the heap, and the integer
elements in myIntArray are value types, allocated on the stack. (While
you can box a value type so that it can be treated like a reference
type, as explained in Chapter 6, it is not necessary or desirable to
box the integers in an array.) By contrast, an array that contains
reference types, such as Employee or Button, will contain nothing but
references to the elements, which are themselves created on the heap.
Question:
Is that true? And if so, what happens when you return and the stack
gets popped, while a reference to the array created on the heap may
still exist somewhere?