title: Convert string with hex values to byte array
body: <p>I have this: </p>
  
  <pre><code>string x = "0X65 00 0X94 0X81 00 0X40 0X7E 00 0XA0 0XF0 00 0X80 0X2C 00 0XA9 0XA";
  </code></pre>
  
  <p>And I would like this: </p>
  
  <pre><code>byte[] x = {0X65, 00, 0X94, 0X81, 00, 0X40, 0X7E, 00, 0XA0, 0XF0, 00, 0X80, 0X2C, 00, 0XA9, 0XA};
  </code></pre>
  
  <p>When I try something like:</p>
  
  <pre><code>string[] t = x.split(' ');
  byte[] byte = new byte[t.Legnth];
  for (int i = 0; i &lt; byte.Length; i++)
              {
                  byte[i] = Convert.ToByte(t[i]);
              }
  </code></pre>
  
  <p>the byte is encoded to some other value. I'm not familiar with byte formats, I'm just trying to go directly from a string of bytes separated by a space to having them in the array.</p>