// 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();

相关文章:

  • 2022-01-12
  • 2021-12-19
  • 2021-04-11
  • 2021-06-04
  • 2021-06-12
  • 2022-01-28
  • 2022-01-27
  • 2022-12-23
猜你喜欢
  • 2021-04-03
  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
  • 2021-12-01
  • 2021-11-11
  • 2021-11-14
相关资源
相似解决方案