本文主要是介绍(VB.Net)Integer转 Byte数组,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、Integer转单个字节
Public Function iByte(ByVal i As Integer) As ByteDim b() As Byte = BitConverter.GetBytes(i)Return b(0)
End Function
2、Integer转双字节
'低字节在前,高字节在后
Public Function iByte2(ByVal i As Integer) As Byte()Dim btemp() As Byte = {0, 0}Dim b() As Byte = BitConverter.GetBytes(i)btemp(0) = b(1)btemp(1) = b(0)Return btemp
End Function
3、Integer转四字节
'低字节在前,高字节在后
Public Function iByte4(ByVal i As Integer) As Byte()Dim btemp() As Byte = {0, 0, 0, 0}Dim b() As Byte = BitConverter.GetBytes(i)btemp(0) = b(3)btemp(1) = b(2)btemp(2) = b(1)btemp(3) = b(0)Return btemp
End Function
这篇关于(VB.Net)Integer转 Byte数组的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!