You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Extensions/BitArrayExtensions.cs

24 lines
676 B

using System;
using ZeroLevel.Collections;
namespace ZeroLevel.Extensions
{
internal static class BitArrayExtensions
{
// <summary>
// serialize a bitarray.
// </summary>
//<param name="bits">The bit array to convert</param>
// <returns>The bit array converted to an array of bytes.</returns>
internal static byte[] ToBytes(this FastBitArray bits)
{
if (bits == null) return null;
var numBytes = bits.Count / 8;
if (bits.Count % 8 != 0) numBytes++;
var bytes = new byte[numBytes];
bits.CopyTo(bytes, 0);
return bytes;
}
}
}

Powered by TurnKey Linux.