点击或拖拽改变大小

HslExtensionToHexBytes 方法

将16进制的字符串转化成Byte数据,将检测每2个字符转化,也就是说,中间可以是任意字符
Converts a 16-character string into byte data, which will detect every 2 characters converted, that is, the middle can be any character

命名空间:  HslCommunication
程序集:  HslCommunication (在 HslCommunication.dll 中) 版本:11.8.2.0 (11.8.2.0)
语法
public static byte[] ToHexBytes(
	this string value
)

参数

value
类型:SystemString

[缺少 "M:HslCommunication.HslExtension.ToHexBytes(System.String)" 的 <param name="value"/> 文档]

返回值

类型:Byte
转换后的字节数组

备注

在 Visual Basic 和 C# 中,这个方法可以当成为类型 String 的实例方法来调用。在采用实例方法语法调用这个方法时,请省略第一个参数。请参考 扩展方法 (Visual Basic)扩展方法 (C# 编程指南) 获取更多信息。
备注
参数举例:AA 01 34 A8
示例
HexStringToBytes示例
// str无论是下面哪种情况,都是等效的
string str = "13 A6 15 85 5B 05 12 36 F2 27";
//string str = "13-A6-15-85-5B-05-12-36-F2-27";
//string str = "13A615855B051236F227";
//string str = "13_A6_15_85_5B_05_12_36_F2_27";

byte[] b1 = SoftBasic.HexStringToBytes( str );
// b1 = new byte[] { 0x13, 0xA6, 0x15, 0x85, 0x5B, 0x05, 0x12, 0x36, 0xF2, 0x27 };
参见