I'm utilizing the algorithm of this question: Convert List<boolean> to String (the choosen answer)
But I'm dealing with the length of the BitArray when this is reversed. I mean if my BitArray length was 12, when I reverse it I need to have the length 12 and not 16.
I can imagine I need to add the count information into the string result. But I'm not sure if this would be right. How could I get the same bitArray with the same length?
Current Code:
private void Button_Click_1(object sender, RoutedEventArgs e)
{
var values = new BitArray(12);
values[0] = true;
values[1] = true;
values[2] = true;
values[3] = true;
values[4] = true;
values[5] = true;
values[6] = true;
values[7] = true;
values[8] = false;
values[9] = true;
values[10] = true;
values[11] = false;
var bytes = new byte[(values.Length + 7) / 8];
values.CopyTo(bytes, 0);
var result = Convert.ToBase64String(bytes);
var bytes2 = Convert.FromBase64String(result);
var values2 = new BitArray(12);
for (int i = 0; i < values2.Count; i++)
{
var temp = bytes - 1;
}
}