在VB.NET中声明字节数组 [英] Declaring a byte array in VB.NET

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

问题描述

声明字节数组时,以下内容之间有什么区别?是一个,还是只是两种不同的方式来做同一件事?

When declaring a byte array, what is the difference between the following? Is there one, or are these just two different ways of going about the same thing?

Dim var1 As Byte()
Dim var2() As Byte

推荐答案

没有区别.

规范中的报价(2003年规范,但与2010年规范相同,可以下载此处):

Quotes from the spec (2003 spec, but same in the 2010 spec as can be downloaded here):

数组类型.

还可以通过在变量名称上放置数组类型修饰符或数组初始化修饰符来声明变量为数组类型.

为清楚起见,在同一声明中的变量名称和类型名称上都使用数组类型修饰符是无效的.

For clarity, it is not valid to have an array type modifier on both a variable name and a type name in the same declaration.

以下是规格说明中的示例,其中显示了所有选项:

And below is the sample from the spec that shows all the options:

Module Test
    Sub Main()
        Dim a1() As Integer    ' Declares 1-dimensional array of integers.
        Dim a2(,) As Integer   ' Declares 2-dimensional array of integers.
        Dim a3(,,) As Integer  ' Declares 3-dimensional array of integers.

        Dim a4 As Integer()    ' Declares 1-dimensional array of integers.
        Dim a5 As Integer(,)   ' Declares 2-dimensional array of integers.
        Dim a6 As Integer(,,)  ' Declares 3-dimensional array of integers.

        ' Declare 1-dimensional array of 2-dimensional arrays of integers 
        Dim a7()(,) As Integer
        ' Declare 2-dimensional array of 1-dimensional arrays of integers.
        Dim a8(,)() As Integer

        Dim a9() As Integer() ' Not allowed.
    End Sub
End Module

从注释中可以看出,a1和a4做相同的事情.

And as can be seen in the comments, a1 and a4 does the same thing.

这篇关于在VB.NET中声明字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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