title: Function convert Hex String to BitArray C#
body: <p>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 <strong>Convert.ToInt64</strong> function is <em>endian specific</em>. 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???</p>
  
  <pre><code>public BitArray convertHexToBitArray(string hexData)
      {
          string binary_values = "";
          BitArray binary_array;
  
              if (hexData.Length &lt;= "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 &lt; binary_array.Length; i++)
                  {
                      if (binary_values[i] == '0')
                      {
                          binary_array[i] = false;
                      }
                      else
                      {
                          binary_array[i] = true;
                      }
                  }
              }
     }
  </code></pre>
  
  <p>I removed most of the error / exception handling to keep this to size so plz forgive that. </p>