namespace Cryptic Utilities Binary static class ByteTools public const

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
namespace Cryptic.Utilities.Binary
{
static class ByteTools
{
public const int ByteSize = 8;
public static bool [] Split (byte x)
{
bool [] bits = new bool [ByteSize];
for (int i = 0; i < ByteSize; i++)
bits [x] = x.GetBit (x);
return bits;
}
public static byte Join (bool [] bits)
{
byte x = 0;
for (int i = 0; i < ByteSize; i++)
x = x.SetBit (i, bits [i]);
return x;
}
}
}