/// <summary> /// Returns the sub bit array from the given <paramref name="bitArray"/> as an <see langword=""="UInt64"/> /// value. The sub bit array, left or right, is selected by the given <paramref name="getFromLeftBits"/> /// boolean. /// </summary> public static ulong ToUInt64(IReadOnlyDuoBitArray bitArray, bool getFromLeftBits) { var byteArray = getFromLeftBits ? bitArray .GetLeftBits(0, 8 * sizeof(ulong)) .ToByteArray() : bitArray .GetRightBits(0, 8 * sizeof(ulong)) .ToByteArray(); return(BitConverter.ToUInt64(byteArray, 0)); }