• 获取数据到字节-位的显示


      // Int32 num1 = 4;
                //long num1 = 4;
                Int64 num1 = 4;
     
     
     
                num1 = num1 << 1;//右移动
     
     
                byte[] bs = BitConverter.GetBytes(num1);
     
                BitArray arr = new BitArray(bs);
     
                //设置第四位为打开状态
                //arr[4] = true;
               
     
                var sb = new StringBuilder();
                for (int i = arr.Length-1; i >=0; i--)
                {
                    if (arr[i] == true )
                    {
                        sb.Append("1");
                    }
                    else
                    {
                        sb.Append("0");
                    }
                }
     
               
     
               
     
                Console.WriteLine(string.Format("Length is  :{0}",arr.Length));
                Console.WriteLine(sb.ToString());
     
     
     
     
                Console.WriteLine(Convert.ToInt64(sb.ToString(),2));
                Console.ReadKey();
  • 相关阅读:
    053-157
    053-496
    053-128
    053-167
    053-250
    053-674
    离职申请
    日记


  • 原文地址:https://www.cnblogs.com/micro-chen/p/4195612.html
Copyright © 2020-2023  润新知