title: convert string array of byte values to a byte array
body: <p>I have a textbox on a form where a person types in a byte array into in the format shown below.</p>
  
  <p>My question is how can I then convert the string array produced into a byte array of the same values?</p>
  
  <p>so this would be entered into the text box :</p>
  
  <pre><code>0x11, 0x01, 0x49, 0x4D, 0x41, 0x47, 0x45, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x53, 0x75, 0x6D, 0x6D, 0x61, 0x72, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  </code></pre>
  
  <p>the following code then splits it and converts it to a byte array</p>
  
  <pre><code>string text = txtChecksumText.Text;
          string[] parts = text.Split(new string[] { ", " }, StringSplitOptions.None);
          byte[] bytes = new byte[parts.Length];
  
          for (int i = 0; i &lt; parts.Length; i++)
          {
              bytes[i] = Convert.ToByte(parts[i], 16); // this isn't working as expected
              txtResponse.Text += Environment.NewLine + "     " + i + " = " + parts[i] + " = " + bytes[i].ToString() ;
          }
  </code></pre>
  
  <p>and the response to show it isn't working</p>
  
  <pre><code> 0 = 0x11 = 17
   1 = 0x01 = 1
   2 = 0x49 = 73
   3 = 0x4D = 77
   4 = 0x41 = 65
   5 = 0x47 = 71
   6 = 0x45 = 69
   7 = 0x31 = 49
   8 = 0x00 = 0
   9 = 0x00 = 0
   10 = 0x00 = 0
   11 = 0x00 = 0
   12 = 0x00 = 0
   13 = 0x00 = 0
   14 = 0x00 = 0
   15 = 0x00 = 0
   16 = 0x00 = 0
   17 = 0x00 = 0
   18 = 0x00 = 0
   19 = 0x00 = 0
   20 = 0x00 = 0
   21 = 0x00 = 0
   22 = 0x00 = 0
   23 = 0x01 = 1
   24 = 0x53 = 83
   25 = 0x75 = 117
   26 = 0x6D = 109
   27 = 0x6D = 109
   28 = 0x61 = 97
   29 = 0x72 = 114
   30 = 0x79 = 121
   31 = 0x00 = 0
   32 = 0x00 = 0
   33 = 0x00 = 0
   34 = 0x00 = 0
   35 = 0x00 = 0
   36 = 0x00 = 0
   37 = 0x00 = 0
   38 = 0x00 = 0
   39 = 0x00 = 0
   40 = 0x00 = 0
   41 = 0x00 = 0
   42 = 0x00 = 0
   43 = 0x00 = 0
   44 = 0x00 = 0
   45 = 0x00 = 0
   46 = 0x00 = 0
   47 = 0x00 = 0
   48 = 0x00 = 0
   49 = 0x00 = 0
   50 = 0x00 = 0
   51 = 0x00 = 0
   52 = 0x00 = 0
   53 = 0x00 = 0
   54 = 0x00 = 0
   55 = 0x00 = 0
  </code></pre>
  
  <p>Just to be clear, the 0x11 should come back as a byte 11 not byte 17, same with all the others I'm not trying to convert to decimal i'm trying to convert the string of literal bytes to a byte array for check-sum creation</p>