From 6d96dbd0366e4b8297e4f7e7fe313265ba92b680 Mon Sep 17 00:00:00 2001 From: parallelbgls Date: Thu, 24 Nov 2016 16:34:20 +0800 Subject: [PATCH] Add GetString Function in ValueHelper --- Modbus.Net/Modbus.Net/ValueHelper.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Modbus.Net/Modbus.Net/ValueHelper.cs b/Modbus.Net/Modbus.Net/ValueHelper.cs index 303af5a..377ff6d 100644 --- a/Modbus.Net/Modbus.Net/ValueHelper.cs +++ b/Modbus.Net/Modbus.Net/ValueHelper.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using System.Text; namespace Modbus.Net { @@ -386,6 +387,21 @@ namespace Modbus.Net return t; } + /// + /// 将byte数组中相应的位置转换为字符串 + /// + /// + /// + /// + /// + /// + public virtual string GetString(byte[] data, int count, ref int pos, Encoding encoding) + { + string t = encoding.GetString(data, pos, count); + pos += count; + return t; + } + /// /// 将byte数组中相应的位置转换为8个bit数字 ///