开发者

Are the values of array elements defined upon defining an array?

I feel quite silly asking this, but I couldn't find a d开发者_如何学JAVAefinite 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜