I created the following function which will do as requested (convert HEX string to BitArray). I am not sure about the efficiency of the function, but my main problem now is that the Convert.ToInt64 function is endian specific. When this is ported over to alternate chipsets we will get different results (or exceptions). So can anyone think of an alternate way to do this conversion???
public BitArray convertHexToBitArray(string hexData)
{
string binary_values = "";
BitArray binary_array;
if (hexData.Length <= "FFFFFFFFFFFFFFFF".Length) // Max Int64
{
binary_values = Convert.ToString(Convert.ToInt64(hexData, 16), 2);
binary_array = new BitArray(binary_values.Length);
for (int i = 0; i < binary_array.Length; i++)
{
if (binary_values[i] == '0')
{
binary_array[i] = false;
}
else
{
binary_array[i] = true;
}
}
}
}
I removed most of the error / exception handling to keep this to size so plz forgive that.