/// <summary>
 /// Procedure to copy BitArray values to byte array from a given index
 /// </summary>
 /// <param name="array">Byte array</param>
 /// <param name="arrayIndex">Start copy index</param>
 public void CopyTo(byte[] array, int arrayIndex)
 {
     Parallel.For(0, intraBitArray.Count,
                  (i, state) =>
     {
         try
         {
             if (intraBitArray[i] == true)
             {
                 FirstSectionOfOperations.SetIbit(7 - (i + arrayIndex) % 8, ref (array[(array.Count() - 1) - ((int)((arrayIndex + i) / 8))]));
             }
             else
             {
                 FirstSectionOfOperations.TakeOffIbit(7 - (i + arrayIndex) % 8, ref (array[(array.Count() - 1) - ((int)((arrayIndex + i) / 8))]));
             }
         }
         catch
         { }
     });
 }
        public BitArray(IEnumerable <byte> inputByteList, int byteLength)
        {
            intraBitArray = new List <bool>();
            Func <byte, List <bool> > transformByteToListBools = new Func <byte, List <bool> >((element) => {
                List <bool> tempList = new List <bool>();
                for (int i = 0; i < byteLength; i++)
                {
                    tempList.Add(false);
                }
                for (int i = 0; i < byteLength; i++)
                {
                    tempList[i] = FirstSectionOfOperations.getIbit(element, i) == 1 ? true : false;
                }
                tempList.Reverse();
                return(tempList);
            });

            inputByteList = inputByteList.Reverse().ToList();
            intraBitArray = (from element in inputByteList.AsParallel() select transformByteToListBools(element)).SelectMany(x => x).ToList();
            IsReadOnly    = false;
        }
        public void getBitArrayFromByteArr(List <byte> inputArray)
        {
            intraBitArray = new List <bool>();
            Func <byte, List <bool> > transformByteToListBools = new Func <byte, List <bool> >((element) =>
            {
                var tempList = new List <bool>()
                {
                    false, false, false, false, false, false, false, false
                };
                for (int i = 0; i < 8; i++)
                {
                    tempList[i] = FirstSectionOfOperations.getIbit(element, i) == 1 ? true : false;
                }
                tempList.Reverse();
                return(tempList);
            });

            inputArray.Reverse();
            intraBitArray = (from element in inputArray.AsParallel() select transformByteToListBools(element)).SelectMany(x => x).ToList();

            IsReadOnly = false;
        }