Reputation: 12092
I feel quite silly asking this, but I couldn't find a definite answer anywhere. in vb.net, how are the array elements defined (if they are defined) for, for example:
Dim myarray(5) as int
does, at this point in time, myarray(3) for example have a defined value? If so, what is it?
Upvotes: 2
Views: 61
Reputation: 17845
From the MSDN documentation for the Dim statement:
If you declare the length of an array but do not initialize its elements, each element is initialized as if it were a separate variable.
Essentially, value types will be initialized to their default value (0 for numeric types), and reference types will be initialized to Nothing.
Upvotes: 2