在Visual Basic中数组的大小? [英] Size of array in Visual Basic?

查看:210
本文介绍了在Visual Basic中数组的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经试过这code在VB:

I've tried this code in VB:

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

的输出为2。任何人任何想法,为什么?

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

推荐答案

如果您正在使用C / C ++ / C#语言中,你所使用的声明数组时,与在若干要素阵列中的

If you are used to C/C++/C# languages you are used that when declaring an array to initialize it with the number of elements in the array.

C# : byte a[] = new byte[1]

将宣布一个字节数组1个元素(UPPERBOUND = 0)

will declare a byte array with 1 element (upperBound = 0)

该行为是在VB不同的地方,声明数组时重新初始化$ P $使用的参数psents在 UPPERBOUND 的数组。

The behavior is different in VB where, when declaring an array the parameter used in initialization represents the UpperBound of the array.

VB.NET: Dim a(1) As Byte

将宣布一个字节数组2个元素(UPPERBOUND = 1)

will declare a byte array with 2 elements (upperBound = 1)

这篇关于在Visual Basic中数组的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆