zoukankan      html  css  js  c++  java
  • 把字符串加工成16进制的字节数组并返回

      //把字符串加工成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;
            }

    ////////////////////////////////
    ////////Sixi. Let it be.../////
    //////////////////////////////

  • 相关阅读:
    计算最大公约数 Exercise05_14
    求满足n^2>12000的n的最大值 Exercise05_13
    依赖注入(DI)
    spring容器
    基于xml文件的bean的配置
    小试牛刀 spring的HelloWorld
    spring 装配Bean
    spring介绍
    hibernate相关类与接口
    hibernate 预习
  • 原文地址:https://www.cnblogs.com/sixiweb/p/1430671.html
Copyright © 2011-2022 走看看