title: fast hex to binary conversion method in .net
body: <p>I am developing an application in C#.net. I have to do a quick hex to binary conversion. What I have done is... </p>
  
  <pre><code>rtpPTypeNum = string.Join(string.Empty, udp.Payload.ToHexadecimalString().Substring(2, 2).Select(C =&gt; Convert.ToString(Convert.ToInt32(C.ToString(), 16), 2).PadLeft(4, '0'))).Substring(1, 7);
  </code></pre>
  
  <p>I have checked its performance, but this is not good enough for me.</p>
  
  <p><code>udp.Payload.ToHexadecimalString()</code> returns a string of hex digits.</p>
  
  <p>In this conversion I have to do around 9000 iterations.</p>
  
  <p>Can you give me a better method?</p>