在VB.NET的字节数组的数组 [英] An array of array of bytes in VB.NET

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

问题描述

我需要一个数组,数组中的每个项目就是这样一个字节数组,但我不知道该怎么办了:

 暗淡作为XX数组XX(0)*为字节* = {&放大器; H12,和放大器; HFF}XX(1)*为字节* = {&放大器; H45,和放大器; HFE}


解决方案

您可以嵌套或锯齿状的字节数组是这样的:

 暗淡myBytes(6)()为字节

这将创建6字节数组空数组。外阵列中的每个元素将是没有,直到你将数组分配给它,就像这样:

  myBytes(0)=新的字节(){&安培; H12,和放大器; HFF}

但是,它很可能是一个更好的主意,使列表字节数组的,像这样的:

 昏暗myBytes作为新的列表(字节())

,直到你把一些字节数组到它这将创建一个字节数组的一个空列表,这会留下空的,像这样的:

  myBytes.Add(新的字节(){&安培; H12,和放大器; HFF})

与嵌套阵列,列表(字节())将自动扩展为你把它保存尽可能多的字节数组。

有关更具体的建议,请告诉我们你想要做的事。

I need an array and each item in the array is an array of bytes like this, but I'm not sure how to do the:

Dim xx as array

xx(0) *as byte* = {&H12, &HFF}

xx(1) *as byte* = {&H45, &HFE}

解决方案

You can make a nested or "jagged" byte array like this:

Dim myBytes(6)() As Byte

This will create an empty array of 6 byte arrays. Each element in the outer array will be Nothing until you assign an array to it, like this:

 myBytes(0) = New Byte() { &H12, &Hff }

However, it would probably be a better idea to make a List of byte arrays, like this:

Dim myBytes As New List(Of Byte())

This will create an empty list of byte array, which will stay empty until you put some byte arrays into it, like this:

myBytes.Add(New Byte() { &H12, &Hff })

Unlike the nested array, a List(Of Byte()) will automatically expand to hold as many byte arrays as you put into it.

For more specific advice, please tell us what you're trying to do.

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

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