且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将整数转换为字节数组VB.net

更新时间:2022-03-16 06:01:35

您可以使用(32位(4字节))转换为字节数组。 bitconverter%28v = vs.110%29.aspx rel = noreferrer> BitConverter 类。

You can convert an integer (32 bit (4 byte)) to a byte array using the BitConverter class.

Dim result As Byte() = BitConverter.GetBytes(-95I)

Dim b1 As Byte = result(0) '161
Dim b2 As Byte = result(1) '255
Dim b3 As Byte = result(2) '255
Dim b4 As Byte = result(3) '255