using System.Collections;
using System.Collections.Generic;
public static void Main()
int[] test1 = { 24, 85, 0 };
List<byte[]> byteArrays = new List<byte[]>();
for(int i = 0; i < test1.Length; i++)
BitArray arrayOfBits = new BitArray(new int[] { test1[i] });
bool[] bits = new bool[arrayOfBits.Count];
arrayOfBits.CopyTo(bits, 0);
byte[] bitValues = bits.Select(bit => (byte)(bit ? 1 : 0)).ToArray();
byte[] final = new byte[8];
for(int j = 0; j < 8; j++)
for(int i = byteArrays.Count() - 1; i >= 0; i--)
foreach(var v in byteArrays[i])
joinBits = string.Concat(joinBits, v.ToString());
Console.WriteLine("\n{0}", joinBits);
int makenums = Convert.ToInt32(joinBits);
Console.WriteLine("\n{0}",makenums);