Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从vb.net中的字节数组中获取某些字节_.net_Vb.net_Arrays_Byte - Fatal编程技术网

从vb.net中的字节数组中获取某些字节

从vb.net中的字节数组中获取某些字节,.net,vb.net,arrays,byte,.net,Vb.net,Arrays,Byte,我有一个字节数组,其中包含文件()中的字节 现在我想从数组中获取第二批4字节,并将它们转换为整数 类似于bytearray.get(4[start],4[length]) "叫它: Dim b() As Byte = {1, 2, 3, 4, 5, 6} Dim x As Integer = ByteArrayToInteger(b, 0, 3) "叫它: Dim b() As Byte = {1, 2, 3, 4, 5, 6} Dim x As Integer = ByteArrayToIn

我有一个字节数组,其中包含文件()中的字节 现在我想从数组中获取第二批4字节,并将它们转换为整数 类似于
bytearray.get(4[start],4[length])

"叫它:

Dim b() As Byte = {1, 2, 3, 4, 5, 6}
Dim x As Integer = ByteArrayToInteger(b, 0, 3)
"叫它:

Dim b() As Byte = {1, 2, 3, 4, 5, 6}
Dim x As Integer = ByteArrayToInteger(b, 0, 3)

请注意,要将字节转换为整数,您至少需要4个字节才能进行转换,否则将引发异常。我知道,但我认为这个答案太复杂了,上面的答案似乎很简单。这是一种更好的方法吗?这是一种更灵活的方法。注意,要将字节转换为整数,您至少需要4个字节才能进行转换,否则将抛出一个异常。我知道,但我认为这个答案太复杂了,上面的答案似乎很简单。这样做更好吗?这样做更灵活
Dim b() As Byte = {1, 2, 3, 4, 5, 6}
Dim x As Integer = ByteArrayToInteger(b, 0, 3)