Size of array in Visual Basic?

前端 未结 5 961
一向
一向 2020-12-09 09:10

I\'ve tried this code in VB:

Dim a(1) As Byte
Console.WriteLine(a.Length)

The output is \"2\". Anyone any idea why?

5条回答
  •  离开以前
    2020-12-09 09:18

    Array starts from position 0. You are defining two positions.

    If you want only 1 position, then:

    Dim a(0) As Byte
    

    and you will get a.Length as 1.

提交回复
热议问题