zoukankan      html  css  js  c++  java
  • C# 整数和byte数组互换

       1:          public static byte[] int2Byte(int intValue)
       2:          {
       3:              byte[] b = new byte[4];
       4:              for (int i = 0; i < 4; i++)
       5:              {
       6:                  b[i] = (byte)(intValue >> 8 * (i) & 0xFF);
       7:              }
       8:              return b;
       9:          }
      10:   
      11:          // 将iSource转为长度为iArrayLen的byte数组,字节数组的低位是整型的低字节位
      12:          public static byte[] int2Byte(int iSource, int len)
      13:          {
      14:              byte[] b = new byte[len];
      15:              for (int i = 0; (i < 4) && (i < len); i++)
      16:              {
      17:                  b[i] = (byte)(iSource >> 8 * i & 0xFF);
      18:              }
      19:              return b;
      20:          }
      21:   
      22:          // 将byte数组bRefArr转为一个整数,字节数组的低位是整型的低字节位
      23:          public static int byte2Int(byte[] b)
      24:          {
      25:              int iOutcome = 0;
      26:              byte bLoop;
      27:              for (int i = 0; i < 4; i++)
      28:              {
      29:                  bLoop = b[i];
      30:                  iOutcome += (bLoop & 0xFF) << (8 * i);
      31:              }
      32:              return iOutcome;
      33:          }
    http://www.kissit.com.cn/
  • 相关阅读:
    亲历dataguard的一些经验问答题
    [转]ORA-38500: USING CURRENT LOGFILE option not available without stand
    修改npm全局安装模式的路径
    Vue 环境搭建
    Linux下查看系统版本号信息的方法
    每天一个Linux命令(12):su命令
    Ubuntu 首次给root用户设置密码
    适用于Linux的windows子系统
    IDEA的terminal设置成Linux的终端一样
    Windows模拟linux终端工具Cmder+Gow
  • 原文地址:https://www.cnblogs.com/Junelee1211/p/2382246.html
Copyright © 2011-2022 走看看