title: Passing a hex value in app.config file
body: <p>I am working on a c# web service. I have a special requirement where I need a configurable hexadecimal value in my code. I need to copy this hexadecimal value in a byte variable. I am trying to pass it in app.config file through appSettings.</p>
  
  <p>For e.g.</p>
  
  <pre><code>byte ASCII_VALUE = 0xA5;
  </code></pre>
  
  <p>I want to get this 0xA5 from the app.config file and copy it to ASCII_VALUE.</p>
  
  <p>I am currently using the following code in app.config file:</p>
  
  <pre><code>&lt;appSettings&gt;
    &lt;add key="Ascii_value" value="0xA5"/&gt;
  &lt;/appSettings&gt;
  </code></pre>
  
  <p>and in my c# code I am doing:</p>
  
  <pre><code>byte ASCII_VALUE = (byte)ConfigurationManager.AppSettings["Ascii_value_for_pound"];
  </code></pre>
  
  <p>But as this is a string it wont convert it to byte value directly.</p>
  
  <p>I also tried</p>
  
  <pre><code>&lt;appSettings&gt;
    &lt;add key="Ascii_value" value="&amp;#xA5;"/&gt;
  &lt;/appSettings&gt;
  </code></pre>
  
  <p>and the same code in c#. But I am still not able to figure out as what to do to get the hex value. </p>
  
  <p>Any idea Guys??? Please help.</p>
  
  <p>Thanks a lot in advance.</p>