//把字符串加工成16进制的字节数组并返回(必须要保证数据格式的正确性<字符个数为偶数>)
        public byte[] GetHEXByteArray(string sendvalue)
        {
            
int sendLength = sendvalue.Length / 2;
            
byte[] StrBuffer = new byte[sendLength];
            
string hexstring = "";
            
int k = 0;
            
for (int i = 0; i < sendvalue.Length; )
            {
                hexstring 
= sendvalue.Substring(i, 2);
                
int j;
                j 
= int.Parse(hexstring, System.Globalization.NumberStyles.HexNumber);
                StrBuffer[k] 
= (byte)j;
                i 
+= 2;
                k
++;
            }
            
return StrBuffer;
        }

相关文章:

  • 2022-12-23
  • 2021-07-16
  • 2021-08-16
  • 2022-12-23
  • 2021-06-15
  • 2021-06-20
  • 2022-12-23
  • 2021-11-25
猜你喜欢
  • 2021-06-11
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2021-09-10
相关资源
相似解决方案