From 33ad2683151cbd5ab64b8881b4db5a8d5cb0e154 Mon Sep 17 00:00:00 2001 From: smartwyy <645583145@qq.com> Date: Mon, 27 May 2024 14:55:58 +0800 Subject: [PATCH] =?UTF-8?q?string=E5=92=8Cbytearray=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HybirdFrameworkCore/Utils/BitUtls.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/HybirdFrameworkCore/Utils/BitUtls.cs b/HybirdFrameworkCore/Utils/BitUtls.cs index 8c4f63a..fcc87b8 100644 --- a/HybirdFrameworkCore/Utils/BitUtls.cs +++ b/HybirdFrameworkCore/Utils/BitUtls.cs @@ -54,17 +54,13 @@ public static class BitUtls if (propertyType == STRING) { - return Convert.ChangeType(Encoding.ASCII.GetString(bytes, start, length/8), propertyType); + byte[] sub = Sub(bytes, start, length); + return Convert.ChangeType(Encoding.ASCII.GetString(sub), propertyType); } if (propertyType == BYTEARRAY) { - length = length / 8; - var bt = new byte[length]; - - for (var i = start; i < start + length; i++) bt[i - start] = bytes[i]; - - return bt; + return Sub(bytes, start, length); } throw new ArgumentException($"参数类型{propertyType}不支持encode!");