点击或拖拽改变大小

SoftBasicBytesReverseByWord 方法

将byte数组按照双字节进行反转,如果为单数的情况,则自动补齐
Reverses the byte array by double byte, or if the singular is the case, automatically

命名空间:  HslCommunication.BasicFramework
程序集:  HslCommunication (在 HslCommunication.dll 中) 版本:11.8.2.0 (11.8.2.0)
语法
public static byte[] BytesReverseByWord(
	byte[] inBytes
)

参数

inBytes
类型:SystemByte
输入的字节信息

返回值

类型:Byte
反转后的数据
备注
例如传入的字节数据是 01 02 03 04, 那么反转后就是 02 01 04 03
示例
BytesReverseByWord示例
byte[] b1 = new byte[] { 0x13, 0xA6, 0x15, 0x85, 0x5B, 0x05, 0x12 };


byte[] buffer = SoftBasic.BytesReverseByWord( b1 );

// buffer的值就为 = new byte[] { 0xA6, 0x13, 0x85, 0x15, 0x05, 0x5B, 0x00, 0x12 };

// 再举个例子

byte[] b2 = new byte[] { 0x13, 0xA6, 0x15, 0x85, 0x5B, 0x05 };

byte[] buffer2 = SoftBasic.BytesReverseByWord( b1 );

// buffer2的值就是 = new byte[] { 0xA6, 0x13, 0x85, 0x15, 0x05, 0x5B };

// 当然,还有一种快捷的方式  buffer3的值就是 = new byte[] { 0xA6, 0x13, 0x85, 0x15, 0x05, 0x5B };
byte[] buffer3 = b1.ReverseByWord( );
参见